summaryrefslogtreecommitdiff
path: root/libdecnumber
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-16 02:54:29 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-16 02:54:29 +0000
commit18f794add773652ebcb8830c89b7651905f28a66 (patch)
treee3b8e61644cb0efde5db5519495eead32d2565c4 /libdecnumber
parentc8afb80579d02770d3d8f80e3414ba6261eceaad (diff)
downloadgcc-18f794add773652ebcb8830c89b7651905f28a66.tar.gz
* decNumber.c (decNumberPower): Constify.
* decNumber.h (decNumberPower): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116990 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libdecnumber')
-rw-r--r--libdecnumber/ChangeLog5
-rw-r--r--libdecnumber/decNumber.c14
-rw-r--r--libdecnumber/decNumber.h4
3 files changed, 15 insertions, 8 deletions
diff --git a/libdecnumber/ChangeLog b/libdecnumber/ChangeLog
index 3661c7c447f..c5dea7f9f56 100644
--- a/libdecnumber/ChangeLog
+++ b/libdecnumber/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-15 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * decNumber.c (decNumberPower): Constify.
+ * decNumber.h (decNumberPower): Likewise.
+
2006-09-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wcast-qual.
diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index a086327d72d..039d19a4592 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -964,13 +964,13 @@ decNumberNormalize (decNumber * res, const decNumber * rhs, decContext * set)
/* Specification restriction: abs(n) must be <=999999999 */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberPower (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberPower (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */
decNumber *allocdac = NULL; /* -> allocated acc buffer, iff used */
- decNumber *inrhs = rhs; /* save original rhs */
+ const decNumber *inrhs = rhs; /* save original rhs */
Int reqdigits = set->digits; /* requested DIGITS */
Int n; /* RHS in binary */
Int i; /* work */
@@ -1117,6 +1117,7 @@ decNumberPower (decNumber * res, decNumber * lhs,
/* we'll invert the lhs now rather than inverting the result later */
if (decNumberIsNegative (rhs))
{ /* was a **-n [hence digits>0] */
+ decNumber * newlhs;
decNumberCopy (&dnOne, dac); /* dnOne=1; [needed now or later] */
#if DECSUBSET
if (set->extended)
@@ -1138,13 +1139,14 @@ decNumberPower (decNumber * res, decNumber * lhs,
status |= DEC_Insufficient_storage;
break;
}
- lhs = alloclhs; /* use the allocated space */
+ newlhs = alloclhs; /* use the allocated space */
}
else
- lhs = (decNumber *) lhsbuff; /* use stack storage */
+ newlhs = (decNumber *) lhsbuff; /* use stack storage */
/* [lhs now points to buffer or allocated storage] */
- decNumberCopy (lhs, dac); /* copy the 1/lhs */
+ decNumberCopy (newlhs, dac); /* copy the 1/lhs */
decNumberCopy (dac, &dnOne); /* restore acc=1 */
+ lhs = newlhs;
#if DECSUBSET
}
#endif
diff --git a/libdecnumber/decNumber.h b/libdecnumber/decNumber.h
index a64a4d5baed..2357fbeab37 100644
--- a/libdecnumber/decNumber.h
+++ b/libdecnumber/decNumber.h
@@ -152,8 +152,8 @@ decNumber *decNumberMultiply (decNumber *, const decNumber *,
const decNumber *, decContext *);
decNumber *decNumberNormalize (decNumber *, const decNumber *, decContext *);
decNumber *decNumberPlus (decNumber *, const decNumber *, decContext *);
-decNumber *decNumberPower (decNumber *, decNumber *, decNumber *,
- decContext *);
+decNumber *decNumberPower (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
decNumber *decNumberQuantize (decNumber *, const decNumber *,
const decNumber *, decContext *);
decNumber *decNumberRemainder (decNumber *, const decNumber *,