summaryrefslogtreecommitdiff
path: root/libdecnumber
diff options
context:
space:
mode:
authorghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-07 04:17:01 +0000
committerghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>2006-09-07 04:17:01 +0000
commitd22a76dbb4c5191f41b7767c6afbf1727f333db2 (patch)
tree5200917b2b0f4279e9d0a776d59ddb3811991471 /libdecnumber
parent25b3017b072278ffa50d8f27fcf015ca37bb7eee (diff)
downloadgcc-d22a76dbb4c5191f41b7767c6afbf1727f333db2.tar.gz
* configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wcast-qual.
* configure, config.in: Regenerate. * decContext.c (decContextStatusToString): Constify. * decContext.h (decContextStatusToString): Likewise. * decNumber.c (decNumberToString, decNumberToEngString, decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide, decNumberDivideInteger, decNumberMax, decNumberMin, decNumberMinus, decNumberPlus, decNumberMultiply, decNumberNormalize, decNumberQuantize, decNumberRescale, decNumberRemainder, decNumberRemainderNear, decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract, decNumberToIntegralValue, decNumberCopy, decToString, decAddOp, decDivideOp, decMultiplyOp, decQuantizeOp, decCompareOp, decCompare, decUnitCompare, decUnitAddSub, decRoundOperand, decCopyFit, decSetCoeff, decGetInt, decNaNs, decGetDigits, decNumberShow, decDumpAr, decCheckOperands, decCheckNumber): Likewise. * decNumber.h (decNumberToString, decNumberToEngString, decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide, decNumberDivideInteger, decNumberMax, decNumberMin, decNumberMinus, decNumberMultiply, decNumberNormalize, decNumberPlus, decNumberQuantize, decNumberRemainder, decNumberRemainderNear, decNumberRescale, decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract, decNumberToIntegralValue, decNumberCopy): Likewise. * decUtility.c (decDensePackCoeff, decDenseUnpackCoeff): Likewise. * decUtility.h (decDensePackCoeff, decDenseUnpackCoeff): Likewise. * decimal128.c (decimal128FromNumber, decimal128ToNumber, decimal128ToString, decimal128ToEngString, decimal128Show): Likewise. * decimal128.h (decimal128ToString, decimal128ToEngString, decimal128FromNumber, decimal128ToNumber): Likewise. * decimal32.c (decimal32FromNumber, decimal32ToNumber, decimal32ToString, decimal32ToEngString, decimal32Show): Likewise. * decimal32.h (decimal32ToString, decimal32ToEngString, decimal32FromNumber, decimal32ToNumber): Likewise. * decimal64.c (decimal64FromNumber, decimal64ToNumber, decimal64ToString, decimal64ToEngString, decimal64Show): Likewise. * decimal64.h (decimal64ToString, decimal64ToEngString, decimal64FromNumber, decimal64ToNumber): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116738 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libdecnumber')
-rw-r--r--libdecnumber/ChangeLog48
-rw-r--r--libdecnumber/config.in33
-rwxr-xr-xlibdecnumber/configure2
-rw-r--r--libdecnumber/configure.ac2
-rw-r--r--libdecnumber/decContext.c2
-rw-r--r--libdecnumber/decContext.h2
-rw-r--r--libdecnumber/decNumber.c218
-rw-r--r--libdecnumber/decNumber.h65
-rw-r--r--libdecnumber/decUtility.c11
-rw-r--r--libdecnumber/decUtility.h4
-rw-r--r--libdecnumber/decimal128.c14
-rw-r--r--libdecnumber/decimal128.h8
-rw-r--r--libdecnumber/decimal32.c14
-rw-r--r--libdecnumber/decimal32.h8
-rw-r--r--libdecnumber/decimal64.c14
-rw-r--r--libdecnumber/decimal64.h8
16 files changed, 247 insertions, 206 deletions
diff --git a/libdecnumber/ChangeLog b/libdecnumber/ChangeLog
index 99096f813ee..3661c7c447f 100644
--- a/libdecnumber/ChangeLog
+++ b/libdecnumber/ChangeLog
@@ -1,3 +1,51 @@
+2006-09-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wcast-qual.
+ * configure, config.in: Regenerate.
+
+ * decContext.c (decContextStatusToString): Constify.
+ * decContext.h (decContextStatusToString): Likewise.
+ * decNumber.c (decNumberToString, decNumberToEngString,
+ decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide,
+ decNumberDivideInteger, decNumberMax, decNumberMin,
+ decNumberMinus, decNumberPlus, decNumberMultiply,
+ decNumberNormalize, decNumberQuantize, decNumberRescale,
+ decNumberRemainder, decNumberRemainderNear,
+ decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract,
+ decNumberToIntegralValue, decNumberCopy, decToString, decAddOp,
+ decDivideOp, decMultiplyOp, decQuantizeOp, decCompareOp,
+ decCompare, decUnitCompare, decUnitAddSub, decRoundOperand,
+ decCopyFit, decSetCoeff, decGetInt, decNaNs, decGetDigits,
+ decNumberShow, decDumpAr, decCheckOperands, decCheckNumber):
+ Likewise.
+ * decNumber.h (decNumberToString, decNumberToEngString,
+ decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide,
+ decNumberDivideInteger, decNumberMax, decNumberMin,
+ decNumberMinus, decNumberMultiply, decNumberNormalize,
+ decNumberPlus, decNumberQuantize, decNumberRemainder,
+ decNumberRemainderNear, decNumberRescale,
+ decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract,
+ decNumberToIntegralValue, decNumberCopy): Likewise.
+ * decUtility.c (decDensePackCoeff, decDenseUnpackCoeff):
+ Likewise.
+ * decUtility.h (decDensePackCoeff, decDenseUnpackCoeff):
+ Likewise.
+ * decimal128.c (decimal128FromNumber, decimal128ToNumber,
+ decimal128ToString, decimal128ToEngString, decimal128Show):
+ Likewise.
+ * decimal128.h (decimal128ToString, decimal128ToEngString,
+ decimal128FromNumber, decimal128ToNumber): Likewise.
+ * decimal32.c (decimal32FromNumber, decimal32ToNumber,
+ decimal32ToString, decimal32ToEngString, decimal32Show):
+ Likewise.
+ * decimal32.h (decimal32ToString, decimal32ToEngString,
+ decimal32FromNumber, decimal32ToNumber): Likewise.
+ * decimal64.c (decimal64FromNumber, decimal64ToNumber,
+ decimal64ToString, decimal64ToEngString, decimal64Show):
+ Likewise.
+ * decimal64.h (decimal64ToString, decimal64ToEngString,
+ decimal64FromNumber, decimal64ToNumber): Likewise.
+
2006-08-21 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* decContext.c (decContextSetStatusFromString): Constify.
diff --git a/libdecnumber/config.in b/libdecnumber/config.in
index 8d23c64bd91..1d4e9a3f98b 100644
--- a/libdecnumber/config.in
+++ b/libdecnumber/config.in
@@ -1,20 +1,5 @@
/* config.in. Generated from configure.ac by autoheader. */
-/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
- systems. This function is required for `alloca.c' support on those systems.
- */
-#undef CRAY_STACKSEG_END
-
-/* Define to 1 if using `alloca.c'. */
-#undef C_ALLOCA
-
-/* Define to 1 if you have `alloca', as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
- */
-#undef HAVE_ALLOCA_H
-
/* Define to 1 if you have the <ctype.h> header file. */
#undef HAVE_CTYPE_H
@@ -66,26 +51,24 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
+/* The size of a `char', as computed by sizeof. */
+#undef SIZEOF_CHAR
+
/* The size of a `int', as computed by sizeof. */
#undef SIZEOF_INT
/* The size of a `long', as computed by sizeof. */
#undef SIZEOF_LONG
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown */
-#undef STACK_DIRECTION
+/* The size of a `short', as computed by sizeof. */
+#undef SIZEOF_SHORT
+
+/* The size of a `void *', as computed by sizeof. */
+#undef SIZEOF_VOID_P
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define if you can safely include both <string.h> and <strings.h>. */
-#undef STRING_WITH_STRINGS
-
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
diff --git a/libdecnumber/configure b/libdecnumber/configure
index 903d2af41db..f9cb0ef5666 100755
--- a/libdecnumber/configure
+++ b/libdecnumber/configure
@@ -2492,7 +2492,7 @@ WARN_CFLAGS=
save_CFLAGS="$CFLAGS"
for option in -W -Wall -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wold-style-definition \
- -Wmissing-format-attribute; do
+ -Wmissing-format-attribute -Wcast-qual; do
as_acx_Woption=`echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh`
echo "$as_me:$LINENO: checking whether $CC supports $option" >&5
diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
index 956ff8d2028..90884a8fe15 100644
--- a/libdecnumber/configure.ac
+++ b/libdecnumber/configure.ac
@@ -40,7 +40,7 @@ AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader])
ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wold-style-definition \
- -Wmissing-format-attribute])
+ -Wmissing-format-attribute -Wcast-qual])
ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long])
# Only enable with --enable-werror-always until existing warnings are
diff --git a/libdecnumber/decContext.c b/libdecnumber/decContext.c
index 8f5b683184e..428c77e191b 100644
--- a/libdecnumber/decContext.c
+++ b/libdecnumber/decContext.c
@@ -109,7 +109,7 @@ decContextDefault (decContext * context, Int kind)
/* (or no) flags are set, a generic constant message is returned. */
/* ------------------------------------------------------------------ */
const char *
-decContextStatusToString (decContext * context)
+decContextStatusToString (const decContext * context)
{
Int status = context->status;
if (status == DEC_Conversion_syntax)
diff --git a/libdecnumber/decContext.h b/libdecnumber/decContext.h
index d2e18db2c05..41c4b52a400 100644
--- a/libdecnumber/decContext.h
+++ b/libdecnumber/decContext.h
@@ -172,7 +172,7 @@ typedef struct
#endif
decContext *decContextDefault (decContext *, int32_t);
decContext *decContextSetStatus (decContext *, uint32_t);
-const char *decContextStatusToString (decContext *);
+const char *decContextStatusToString (const decContext *);
decContext *decContextSetStatusFromString (decContext *, const char *);
#endif
diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index bd6b57b805c..a086327d72d 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -206,29 +206,30 @@ typedef unsigned long long uLong;
#endif
/* Local routines */
-static decNumber *decAddOp (decNumber *, decNumber *, decNumber *,
- decContext *, uByte, uInt *);
+static decNumber *decAddOp (decNumber *, const decNumber *,
+ const decNumber *, decContext *,
+ uByte, uInt *);
static void decApplyRound (decNumber *, decContext *, Int, uInt *);
-static Int decCompare (decNumber * lhs, decNumber * rhs);
-static decNumber *decCompareOp (decNumber *, decNumber *, decNumber *,
+static Int decCompare (const decNumber * lhs, const decNumber * rhs);
+static decNumber *decCompareOp (decNumber *, const decNumber *, const decNumber *,
decContext *, Flag, uInt *);
-static void decCopyFit (decNumber *, decNumber *, decContext *,
+static void decCopyFit (decNumber *, const decNumber *, decContext *,
Int *, uInt *);
-static decNumber *decDivideOp (decNumber *, decNumber *, decNumber *,
+static decNumber *decDivideOp (decNumber *, const decNumber *, const decNumber *,
decContext *, Flag, uInt *);
static void decFinalize (decNumber *, decContext *, Int *, uInt *);
-static Int decGetDigits (Unit *, Int);
+static Int decGetDigits (const Unit *, Int);
#if DECSUBSET
-static Int decGetInt (decNumber *, decContext *);
+static Int decGetInt (const decNumber *, decContext *);
#else
-static Int decGetInt (decNumber *);
+static Int decGetInt (const decNumber *);
#endif
-static decNumber *decMultiplyOp (decNumber *, decNumber *, decNumber *,
- decContext *, uInt *);
-static decNumber *decNaNs (decNumber *, decNumber *, decNumber *, uInt *);
-static decNumber *decQuantizeOp (decNumber *, decNumber *, decNumber *,
- decContext *, Flag, uInt *);
-static void decSetCoeff (decNumber *, decContext *, Unit *,
+static decNumber *decMultiplyOp (decNumber *, const decNumber *,
+ const decNumber *, decContext *, uInt *);
+static decNumber *decNaNs (decNumber *, const decNumber *, const decNumber *, uInt *);
+static decNumber *decQuantizeOp (decNumber *, const decNumber *,
+ const decNumber *, decContext *, Flag, uInt *);
+static void decSetCoeff (decNumber *, decContext *, const Unit *,
Int, Int *, uInt *);
static void decSetOverflow (decNumber *, decContext *, uInt *);
static void decSetSubnormal (decNumber *, decContext *, Int *, uInt *);
@@ -236,17 +237,17 @@ static Int decShiftToLeast (Unit *, Int, Int);
static Int decShiftToMost (Unit *, Int, Int);
static void decStatus (decNumber *, uInt, decContext *);
static Flag decStrEq (const char *, const char *);
-static void decToString (decNumber *, char[], Flag);
+static void decToString (const decNumber *, char[], Flag);
static decNumber *decTrim (decNumber *, Flag, Int *);
-static Int decUnitAddSub (Unit *, Int, Unit *, Int, Int, Unit *, Int);
-static Int decUnitCompare (Unit *, Int, Unit *, Int, Int);
+static Int decUnitAddSub (const Unit *, Int, const Unit *, Int, Int, Unit *, Int);
+static Int decUnitCompare (const Unit *, Int, const Unit *, Int, Int);
#if !DECSUBSET
/* decFinish == decFinalize when no subset arithmetic needed */
#define decFinish(a,b,c,d) decFinalize(a,b,c,d)
#else
static void decFinish (decNumber *, decContext *, Int *, uInt *);
-static decNumber *decRoundOperand (decNumber *, decContext *, uInt *);
+static decNumber *decRoundOperand (const decNumber *, decContext *, uInt *);
#endif
/* Diagnostic macros, etc. */
@@ -275,15 +276,15 @@ uInt decAllocBytes = 0; /* count of bytes allocated */
/* fastest routines (and adds 600+ bytes), so should not normally be */
/* used in 'production'. */
#define DECUNUSED (void *)(0xffffffff)
-static Flag decCheckOperands (decNumber *, decNumber *, decNumber *,
- decContext *);
-static Flag decCheckNumber (decNumber *, decContext *);
+static Flag decCheckOperands (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+static Flag decCheckNumber (const decNumber *, decContext *);
#endif
#if DECTRACE || DECCHECK
/* Optional trace/debugging routines. */
-void decNumberShow (decNumber *); /* displays the components of a number */
-static void decDumpAr (char, Unit *, Int);
+void decNumberShow (const decNumber *); /* displays the components of a number */
+static void decDumpAr (char, const Unit *, Int);
#endif
/* ================================================================== */
@@ -305,14 +306,14 @@ static void decDumpAr (char, Unit *, Int);
/* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */
char *
-decNumberToString (decNumber * dn, char *string)
+decNumberToString (const decNumber * dn, char *string)
{
decToString (dn, string, 0);
return string;
}
char *
-decNumberToEngString (decNumber * dn, char *string)
+decNumberToEngString (const decNumber * dn, char *string)
{
decToString (dn, string, 1);
return string;
@@ -640,7 +641,7 @@ decNumberFromString (decNumber * dn, const char chars[], decContext * set)
/* in which case it has the same effect as decNumberMinus. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberAbs (decNumber * res, decNumber * rhs, decContext * set)
+decNumberAbs (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber dzero; /* for 0 */
uInt status = 0; /* accumulator */
@@ -672,8 +673,8 @@ decNumberAbs (decNumber * res, decNumber * rhs, decContext * set)
/* ------------------------------------------------------------------ */
/* This just calls the routine shared with Subtract */
decNumber *
-decNumberAdd (decNumber * res, decNumber * lhs, decNumber * rhs,
- decContext * set)
+decNumberAdd (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decAddOp (res, lhs, rhs, set, 0, &status);
@@ -695,8 +696,8 @@ decNumberAdd (decNumber * res, decNumber * lhs, decNumber * rhs,
/* C must have space for one digit. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberCompare (decNumber * res, decNumber * lhs, decNumber * rhs,
- decContext * set)
+decNumberCompare (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPARE, &status);
@@ -718,8 +719,8 @@ decNumberCompare (decNumber * res, decNumber * lhs, decNumber * rhs,
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberDivide (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberDivide (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, DIVIDE, &status);
@@ -741,8 +742,8 @@ decNumberDivide (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberDivideInteger (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberDivideInteger (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, DIVIDEINT, &status);
@@ -764,8 +765,8 @@ decNumberDivideInteger (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberMax (decNumber * res, decNumber * lhs, decNumber * rhs,
- decContext * set)
+decNumberMax (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPMAX, &status);
@@ -787,8 +788,8 @@ decNumberMax (decNumber * res, decNumber * lhs, decNumber * rhs,
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberMin (decNumber * res, decNumber * lhs, decNumber * rhs,
- decContext * set)
+decNumberMin (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decCompareOp (res, lhs, rhs, set, COMPMIN, &status);
@@ -811,7 +812,7 @@ decNumberMin (decNumber * res, decNumber * lhs, decNumber * rhs,
/* We simply use AddOp for the subtract, which will do the necessary. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberMinus (decNumber * res, decNumber * rhs, decContext * set)
+decNumberMinus (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber dzero;
uInt status = 0; /* accumulator */
@@ -845,7 +846,7 @@ decNumberMinus (decNumber * res, decNumber * rhs, decContext * set)
/* check operands and apply rounding and overflow/underflow testing. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberPlus (decNumber * res, decNumber * rhs, decContext * set)
+decNumberPlus (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber dzero;
uInt status = 0; /* accumulator */
@@ -876,8 +877,8 @@ decNumberPlus (decNumber * res, decNumber * rhs, decContext * set)
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberMultiply (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberMultiply (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decMultiplyOp (res, lhs, rhs, set, &status);
@@ -898,7 +899,7 @@ decNumberMultiply (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberNormalize (decNumber * res, decNumber * rhs, decContext * set)
+decNumberNormalize (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber *allocrhs = NULL; /* non-NULL if rounded rhs allocated */
uInt status = 0; /* as usual */
@@ -1248,8 +1249,8 @@ decNumberPower (decNumber * res, decNumber * lhs,
/* after the operation is guaranteed to be equal to that of B. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberQuantize (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberQuantize (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decQuantizeOp (res, lhs, rhs, set, 1, &status);
@@ -1277,8 +1278,8 @@ decNumberQuantize (decNumber * res, decNumber * lhs,
/* after the operation is guaranteed to be equal to B. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberRescale (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberRescale (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decQuantizeOp (res, lhs, rhs, set, 0, &status);
@@ -1300,8 +1301,8 @@ decNumberRescale (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberRemainder (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberRemainder (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, REMAINDER, &status);
@@ -1323,8 +1324,8 @@ decNumberRemainder (decNumber * res, decNumber * lhs,
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberRemainderNear (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberRemainderNear (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
decDivideOp (res, lhs, rhs, set, REMNEAR, &status);
@@ -1343,7 +1344,7 @@ decNumberRemainderNear (decNumber * res, decNumber * lhs,
/* No errors are possible and no context is needed. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberSameQuantum (decNumber * res, decNumber * lhs, decNumber * rhs)
+decNumberSameQuantum (decNumber * res, const decNumber * lhs, const decNumber * rhs)
{
uByte merged; /* merged flags */
Unit ret = 0; /* return value */
@@ -1440,7 +1441,7 @@ decNumberSameQuantum (decNumber * res, decNumber * lhs, decNumber * rhs)
/* end sqrt */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberSquareRoot (decNumber * res, decNumber * rhs, decContext * set)
+decNumberSquareRoot (decNumber * res, const decNumber * rhs, decContext * set)
{
decContext workset, approxset; /* work contexts */
decNumber dzero; /* used for constant zero */
@@ -1781,8 +1782,8 @@ decNumberSquareRoot (decNumber * res, decNumber * rhs, decContext * set)
/* C must have space for set->digits digits. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberSubtract (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decNumberSubtract (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
uInt status = 0; /* accumulator */
@@ -1810,7 +1811,7 @@ decNumberSubtract (decNumber * res, decNumber * lhs,
/* the digits setting is ignored. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberToIntegralValue (decNumber * res, decNumber * rhs, decContext * set)
+decNumberToIntegralValue (decNumber * res, const decNumber * rhs, decContext * set)
{
decNumber dn;
decContext workset; /* working context */
@@ -1860,7 +1861,7 @@ decNumberToIntegralValue (decNumber * res, decNumber * rhs, decContext * set)
/* so special values are unchanged and no error is possible. */
/* ------------------------------------------------------------------ */
decNumber *
-decNumberCopy (decNumber * dest, decNumber * src)
+decNumberCopy (decNumber * dest, const decNumber * src)
{
#if DECCHECK
@@ -1881,7 +1882,8 @@ decNumberCopy (decNumber * dest, decNumber * src)
dest->lsu[0] = src->lsu[0];
if (src->digits > DECDPUN)
{ /* more Units to come */
- Unit *s, *d, *smsup; /* work */
+ Unit *d; /* work */
+ const Unit *s, *smsup; /* work */
/* memcpy for the remaining Units would be safe as they cannot */
/* overlap. However, this explicit loop is faster in short cases. */
d = dest->lsu + 1; /* -> first destination */
@@ -1987,14 +1989,14 @@ decNumberZero (decNumber * dn)
}
static void
-decToString (decNumber * dn, char *string, Flag eng)
+decToString (const decNumber * dn, char *string, Flag eng)
{
Int exp = dn->exponent; /* local copy */
Int e; /* E-part value */
Int pre; /* digits before the '.' */
Int cut; /* for counting digits in a Unit */
char *c = string; /* work [output pointer] */
- Unit *up = dn->lsu + D2U (dn->digits) - 1; /* -> msu [input pointer] */
+ const Unit *up = dn->lsu + D2U (dn->digits) - 1; /* -> msu [input pointer] */
uInt u, pow; /* work */
#if DECCHECK
@@ -2214,8 +2216,8 @@ decToString (decNumber * dn, char *string, Flag eng)
/* to make returning as fast as possible, by flagging any allocation. */
/* ------------------------------------------------------------------ */
static decNumber *
-decAddOp (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set, uByte negate, uInt * status)
+decAddOp (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set, uByte negate, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */
@@ -2439,7 +2441,7 @@ decAddOp (decNumber * res, decNumber * lhs,
Flag swapped = 0;
if (padding < 0)
{ /* LHS needs the padding */
- decNumber *t;
+ const decNumber *t;
padding = -padding; /* will be +ve */
bits = (uByte) (rhs->bits ^ negate); /* assumed sign is now that of RHS */
t = lhs;
@@ -2692,7 +2694,7 @@ decAddOp (decNumber * res, decNumber * lhs,
/* ------------------------------------------------------------------ */
static decNumber *
decDivideOp (decNumber * res,
- decNumber * lhs, decNumber * rhs,
+ const decNumber * lhs, const decNumber * rhs,
decContext * set, Flag op, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
@@ -2709,12 +2711,13 @@ decDivideOp (decNumber * res,
Unit *var1 = varbuff; /* -> var1 array for long subtraction */
Unit *varalloc = NULL; /* -> allocated buffer, iff used */
- Unit *var2; /* -> var2 array */
+ const Unit *var2; /* -> var2 array */
Int var1units, var2units; /* actual lengths */
Int var2ulen; /* logical length (units) */
Int var1initpad = 0; /* var1 initial padding (digits) */
- Unit *msu1, *msu2; /* -> msu of each var */
+ Unit *msu1; /* -> msu of each var */
+ const Unit *msu2; /* -> msu of each var */
Int msu2plus; /* msu2 plus one [does not vary] */
eInt msu2pair; /* msu2 pair plus one [does not vary] */
Int maxdigits; /* longest LHS or required acc length */
@@ -2726,7 +2729,8 @@ decDivideOp (decNumber * res,
Int maxexponent = 0; /* DIVIDE maximum exponent if unrounded */
uByte bits; /* working sign */
uByte merged; /* merged flags */
- Unit *target, *source; /* work */
+ Unit *target; /* work */
+ const Unit *source; /* work */
uInt const *pow; /* .. */
Int shift, cut; /* .. */
#if DECSUBSET
@@ -3049,7 +3053,8 @@ decDivideOp (decNumber * res,
if (var1units == var2ulen)
{ /* unit-by-unit compare needed */
/* compare the two numbers, from msu */
- Unit *pv1, *pv2, v2; /* units to compare */
+ Unit *pv1, v2; /* units to compare */
+ const Unit *pv2; /* units to compare */
pv2 = msu2; /* -> msu */
for (pv1 = msu1;; pv1--, pv2--)
{
@@ -3411,15 +3416,15 @@ decDivideOp (decNumber * res,
/* We always have to use a buffer for the accumulator. */
/* ------------------------------------------------------------------ */
static decNumber *
-decMultiplyOp (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set, uInt * status)
+decMultiplyOp (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */
Unit accbuff[D2U (DECBUFFER * 2 + 1)]; /* local buffer (+1 in case DECBUFFER==0) */
Unit *acc = accbuff; /* -> accumulator array for exact result */
Unit *allocacc = NULL; /* -> allocated buffer, iff allocated */
- Unit *mer, *mermsup; /* work */
+ const Unit *mer, *mermsup; /* work */
Int accunits; /* Units of accumulator in use */
Int madlength; /* Units in multiplicand */
Int shift; /* Units to shift multiplicand by */
@@ -3486,7 +3491,7 @@ decMultiplyOp (decNumber * res, decNumber * lhs,
/* multiplier (rhs) and the longer as the multiplicand (lhs) */
if (lhs->digits < rhs->digits)
{ /* swap... */
- decNumber *hold = lhs;
+ const decNumber *hold = lhs;
lhs = rhs;
rhs = hold;
}
@@ -3593,12 +3598,12 @@ decMultiplyOp (decNumber * res, decNumber * lhs,
/* after the operation is guaranteed to be that requested. */
/* ------------------------------------------------------------------ */
static decNumber *
-decQuantizeOp (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set, Flag quant, uInt * status)
+decQuantizeOp (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set, Flag quant, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
decNumber *allocrhs = NULL; /* .., rhs */
- decNumber *inrhs = rhs; /* save original rhs */
+ const decNumber *inrhs = rhs; /* save original rhs */
Int reqdigits = set->digits; /* requested DIGITS */
Int reqexp; /* requested exponent [-scale] */
Int residue = 0; /* rounding residue */
@@ -3776,7 +3781,7 @@ decQuantizeOp (decNumber * res, decNumber * lhs,
/* coefficient comparison if possible. */
/* ------------------------------------------------------------------ */
decNumber *
-decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs,
+decCompareOp (decNumber * res, const decNumber * lhs, const decNumber * rhs,
decContext * set, Flag op, uInt * status)
{
decNumber *alloclhs = NULL; /* non-NULL if rounded lhs allocated */
@@ -3873,7 +3878,7 @@ decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs,
{ /* MAX or MIN, non-NaN result */
Int residue = 0; /* rounding accumulator */
/* choose the operand for the result */
- decNumber *choice;
+ const decNumber *choice;
if (result == 0)
{ /* operands are numerically equal */
/* choose according to sign then exponent (see 754r) */
@@ -3940,7 +3945,7 @@ decCompareOp (decNumber * res, decNumber * lhs, decNumber * rhs,
/* ------------------------------------------------------------------ */
/* This could be merged into decCompareOp */
static Int
-decCompare (decNumber * lhs, decNumber * rhs)
+decCompare (const decNumber * lhs, const decNumber * rhs)
{
Int result; /* result value */
Int sigr; /* rhs signum */
@@ -3977,7 +3982,7 @@ decCompare (decNumber * lhs, decNumber * rhs)
if (lhs->exponent > rhs->exponent)
{ /* LHS exponent larger */
/* swap sides, and sign */
- decNumber *temp = lhs;
+ const decNumber *temp = lhs;
lhs = rhs;
rhs = temp;
result = -result;
@@ -4009,13 +4014,13 @@ decCompare (decNumber * lhs, decNumber * rhs)
/* (the only possible failure is an allocation error) */
/* ------------------------------------------------------------------ */
static Int
-decUnitCompare (Unit * a, Int alength, Unit * b, Int blength, Int exp)
+decUnitCompare (const Unit * a, Int alength, const Unit * b, Int blength, Int exp)
{
Unit *acc; /* accumulator for result */
Unit accbuff[D2U (DECBUFFER + 1)]; /* local buffer */
Unit *allocacc = NULL; /* -> allocated acc buffer, iff allocated */
Int accunits, need; /* units in use or needed for acc */
- Unit *l, *r, *u; /* work */
+ const Unit *l, *r, *u; /* work */
Int expunits, exprem, result; /* .. */
if (exp == 0)
@@ -4129,10 +4134,10 @@ decUnitCompare (Unit * a, Int alength, Unit * b, Int blength, Int exp)
/* (IBM Warwick, UK) for some of the ideas used in this routine. */
/* ------------------------------------------------------------------ */
static Int
-decUnitAddSub (Unit * a, Int alength,
- Unit * b, Int blength, Int bshift, Unit * c, Int m)
+decUnitAddSub (const Unit * a, Int alength,
+ const Unit * b, Int blength, Int bshift, Unit * c, Int m)
{
- Unit *alsu = a; /* A lsu [need to remember it] */
+ const Unit *alsu = a; /* A lsu [need to remember it] */
Unit *clsu = c; /* C ditto */
Unit *minC; /* low water mark for C */
Unit *maxC; /* high water mark for C */
@@ -4556,7 +4561,7 @@ decShiftToLeast (Unit * uar, Int units, Int shift)
/* is returned. */
/* ------------------------------------------------------------------ */
static decNumber *
-decRoundOperand (decNumber * dn, decContext * set, uInt * status)
+decRoundOperand (const decNumber * dn, decContext * set, uInt * status)
{
decNumber *res; /* result structure */
uInt newstatus = 0; /* status from round */
@@ -4595,7 +4600,7 @@ decRoundOperand (decNumber * dn, decContext * set, uInt * status)
/* All fields are updated as required. */
/* ------------------------------------------------------------------ */
static void
-decCopyFit (decNumber * dest, decNumber * src, decContext * set,
+decCopyFit (decNumber * dest, const decNumber * src, decContext * set,
Int * residue, uInt * status)
{
dest->bits = src->bits;
@@ -4643,14 +4648,15 @@ decCopyFit (decNumber * dest, decNumber * src, decContext * set,
/* 0 1 2 3 4 5 6 7 8 9 */
static const uByte resmap[10] = { 0, 3, 3, 3, 3, 5, 7, 7, 7, 7 };
static void
-decSetCoeff (decNumber * dn, decContext * set, Unit * lsu,
+decSetCoeff (decNumber * dn, decContext * set, const Unit * lsu,
Int len, Int * residue, uInt * status)
{
Int discard; /* number of digits to discard */
uInt discard1; /* first discarded digit */
uInt cut; /* cut point in Unit */
uInt quot, rem; /* for divisions */
- Unit *up, *target; /* work */
+ Unit *target; /* work */
+ const Unit *up; /* work */
Int count; /* .. */
#if DECDPUN<=4
uInt temp; /* .. */
@@ -5246,8 +5252,8 @@ decSetOverflow (decNumber * dn, decContext * set, uInt * status)
/* necessary. Underflow is set if the result is Inexact. */
/* ------------------------------------------------------------------ */
static void
-decSetSubnormal (decNumber * dn, decContext * set, Int * residue,
- uInt * status)
+decSetSubnormal (decNumber * dn, decContext * set,
+ Int * residue, uInt * status)
{
decContext workset; /* work */
Int etiny, adjust; /* .. */
@@ -5342,15 +5348,15 @@ decSetSubnormal (decNumber * dn, decContext * set, Int * residue,
/* ------------------------------------------------------------------ */
#if DECSUBSET
static Int
-decGetInt (decNumber * dn, decContext * set)
+decGetInt (const decNumber * dn, decContext * set)
{
#else
static Int
-decGetInt (decNumber * dn)
+decGetInt (const decNumber * dn)
{
#endif
Int theInt; /* result accumulator */
- Unit *up; /* work */
+ const Unit *up; /* work */
Int got; /* digits (real or not) processed */
Int ilength = dn->digits + dn->exponent; /* integral length */
@@ -5472,7 +5478,7 @@ decStrEq (const char *str1, const char *str2)
/* to a qNaN and Invalid operation is set. */
/* ------------------------------------------------------------------ */
static decNumber *
-decNaNs (decNumber * res, decNumber * lhs, decNumber * rhs, uInt * status)
+decNaNs (decNumber * res, const decNumber * lhs, const decNumber * rhs, uInt * status)
{
/* This decision tree ends up with LHS being the source pointer, */
/* and status updated if need be */
@@ -5543,9 +5549,9 @@ decStatus (decNumber * dn, uInt status, decContext * set)
/* ------------------------------------------------------------------ */
/* This may be called twice during some operations. */
static Int
-decGetDigits (Unit * uar, Int len)
+decGetDigits (const Unit * uar, Int len)
{
- Unit *up = uar + len - 1; /* -> msu */
+ const Unit *up = uar + len - 1; /* -> msu */
Int digits = len * DECDPUN; /* maximum possible digits */
uInt const *pow; /* work */
@@ -5584,9 +5590,9 @@ decGetDigits (Unit * uar, Int len)
/* ------------------------------------------------------------------ */
/* this is public so other modules can use it */
void
-decNumberShow (decNumber * dn)
+decNumberShow (const decNumber * dn)
{
- Unit *up; /* work */
+ const Unit *up; /* work */
uInt u, d; /* .. */
Int cut; /* .. */
char isign = '+'; /* main sign */
@@ -5652,13 +5658,13 @@ decNumberShow (decNumber * dn)
/* len is the length of the array in Units */
/* ------------------------------------------------------------------ */
static void
-decDumpAr (char name, Unit * ar, Int len)
+decDumpAr (char name, const Unit * ar, Int len)
{
Int i;
#if DECDPUN==4
- char *spec = "%04d ";
+ const char *spec = "%04d ";
#else
- char *spec = "%d ";
+ const char *spec = "%d ";
#endif
printf (" :%c: ", name);
for (i = len - 1; i >= 0; i--)
@@ -5688,8 +5694,8 @@ decDumpAr (char name, Unit * ar, Int len)
/* The caller is expected to abandon immediately if 1 is returned. */
/* ------------------------------------------------------------------ */
static Flag
-decCheckOperands (decNumber * res, decNumber * lhs,
- decNumber * rhs, decContext * set)
+decCheckOperands (decNumber * res, const decNumber * lhs,
+ const decNumber * rhs, decContext * set)
{
Flag bad = 0;
if (set == NULL)
@@ -5746,9 +5752,9 @@ decCheckOperands (decNumber * res, decNumber * lhs,
/* operation in some valid context (not necessarily the current one). */
/* ------------------------------------------------------------------ */
Flag
-decCheckNumber (decNumber * dn, decContext * set)
+decCheckNumber (const decNumber * dn, decContext * set)
{
- Unit *up; /* work */
+ const Unit *up; /* work */
uInt maxuint; /* .. */
Int ae, d, digits; /* .. */
Int emin, emax; /* .. */
diff --git a/libdecnumber/decNumber.h b/libdecnumber/decNumber.h
index 797e781eaa4..a64a4d5baed 100644
--- a/libdecnumber/decNumber.h
+++ b/libdecnumber/decNumber.h
@@ -130,43 +130,46 @@ typedef struct
/* Conversions */
decNumber *decNumberFromString (decNumber *, const char *, decContext *);
-char *decNumberToString (decNumber *, char *);
-char *decNumberToEngString (decNumber *, char *);
+char *decNumberToString (const decNumber *, char *);
+char *decNumberToEngString (const decNumber *, char *);
/* Operators */
-decNumber *decNumberAbs (decNumber *, decNumber *, decContext *);
-decNumber *decNumberAdd (decNumber *, decNumber *, decNumber *, decContext *);
-decNumber *decNumberCompare (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberDivide (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberDivideInteger (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberMax (decNumber *, decNumber *, decNumber *, decContext *);
-decNumber *decNumberMin (decNumber *, decNumber *, decNumber *, decContext *);
-decNumber *decNumberMinus (decNumber *, decNumber *, decContext *);
-decNumber *decNumberMultiply (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberNormalize (decNumber *, decNumber *, decContext *);
-decNumber *decNumberPlus (decNumber *, decNumber *, decContext *);
+decNumber *decNumberAbs (decNumber *, const decNumber *, decContext *);
+decNumber *decNumberAdd (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberCompare (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberDivide (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberDivideInteger (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberMax (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberMin (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberMinus (decNumber *, const decNumber *, decContext *);
+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 *decNumberQuantize (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberRemainder (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberRemainderNear (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberRescale (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberSameQuantum (decNumber *, decNumber *, decNumber *);
-decNumber *decNumberSquareRoot (decNumber *, decNumber *, decContext *);
-decNumber *decNumberSubtract (decNumber *, decNumber *, decNumber *,
- decContext *);
-decNumber *decNumberToIntegralValue (decNumber *, decNumber *, decContext *);
+decNumber *decNumberQuantize (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberRemainder (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberRemainderNear (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberRescale (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberSameQuantum (decNumber *, const decNumber *, const decNumber *);
+decNumber *decNumberSquareRoot (decNumber *, const decNumber *, decContext *);
+decNumber *decNumberSubtract (decNumber *, const decNumber *,
+ const decNumber *, decContext *);
+decNumber *decNumberToIntegralValue (decNumber *, const decNumber *, decContext *);
/* Utilities */
-decNumber *decNumberCopy (decNumber *, decNumber *);
+decNumber *decNumberCopy (decNumber *, const decNumber *);
decNumber *decNumberTrim (decNumber *);
const char *decNumberVersion (void);
decNumber *decNumberZero (decNumber *);
diff --git a/libdecnumber/decUtility.c b/libdecnumber/decUtility.c
index 83d94565f29..83f388665ad 100644
--- a/libdecnumber/decUtility.c
+++ b/libdecnumber/decUtility.c
@@ -64,7 +64,7 @@
/* No error is possible. */
/* ------------------------------------------------------------------ */
void
-decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift)
+decDensePackCoeff (const decNumber * dn, uByte * bytes, Int len, Int shift)
{
Int cut; /* work */
Int n; /* output bunch counter */
@@ -72,7 +72,7 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift)
uInt dpd; /* densely packed decimal value */
uInt bin; /* binary value 0-999 */
uByte *bout; /* -> current output byte */
- Unit *inu = dn->lsu; /* -> current input unit */
+ const Unit *inu = dn->lsu; /* -> current input unit */
Unit uar[DECMAXUNITS]; /* working copy of units, iff shifted */
#if DECDPUN!=3 /* not fast path */
Unit in; /* current input unit */
@@ -83,7 +83,8 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift)
/* shift the units array to the left by pad digits and copy */
/* [this code is a special case of decShiftToMost, which could */
/* be used instead if exposed and the array were copied first] */
- Unit *target, *source, *first; /* work */
+ Unit *target, *first; /* work */
+ const Unit *source; /* work */
uInt next = 0; /* work */
source = dn->lsu + D2U (digits) - 1; /* where msu comes from */
@@ -211,12 +212,12 @@ decDensePackCoeff (decNumber * dn, uByte * bytes, Int len, Int shift)
/* No error is possible [the redundant 888 codes are allowed]. */
/* ------------------------------------------------------------------ */
void
-decDenseUnpackCoeff (uByte * bytes, Int len, decNumber * dn,
+decDenseUnpackCoeff (const uByte * bytes, Int len, decNumber * dn,
Int bunches, Int odd)
{
uInt dpd = 0; /* collector for 10 bits */
Int n; /* counter */
- uByte *bin; /* -> current input byte */
+ const uByte *bin; /* -> current input byte */
Unit *uout = dn->lsu; /* -> current output unit */
Unit out = 0; /* accumulator */
Int cut = 0; /* power of ten in current unit */
diff --git a/libdecnumber/decUtility.h b/libdecnumber/decUtility.h
index ecd84955688..dec7e269717 100644
--- a/libdecnumber/decUtility.h
+++ b/libdecnumber/decUtility.h
@@ -24,5 +24,5 @@
#define decDenseUnpackCoeff __decDenseUnpackCoeff
#endif
-extern void decDensePackCoeff (decNumber *, uByte *, Int, Int);
-extern void decDenseUnpackCoeff (uByte *, Int, decNumber *, Int, Int);
+extern void decDensePackCoeff (const decNumber *, uByte *, Int, Int);
+extern void decDenseUnpackCoeff (const uByte *, Int, decNumber *, Int, Int);
diff --git a/libdecnumber/decimal128.c b/libdecnumber/decimal128.c
index b8794e7e251..90f400912e4 100644
--- a/libdecnumber/decimal128.c
+++ b/libdecnumber/decimal128.c
@@ -38,8 +38,8 @@
#include "decUtility.h" /* utility routines */
#if DECTRACE || DECCHECK
-void decimal128Show (decimal128 *); /* for debug */
-void decNumberShow (decNumber *); /* .. */
+void decimal128Show (const decimal128 *); /* for debug */
+void decNumberShow (const decNumber *); /* .. */
#endif
/* Useful macro */
@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */
/* power of ten, or if the exponent on a zero had to be clamped. */
/* ------------------------------------------------------------------ */
decimal128 *
-decimal128FromNumber (decimal128 * d128, decNumber * dn, decContext * set)
+decimal128FromNumber (decimal128 * d128, const decNumber * dn, decContext * set)
{
uInt status = 0; /* status accumulator */
Int pad = 0; /* coefficient pad digits */
@@ -184,7 +184,7 @@ decimal128FromNumber (decimal128 * d128, decNumber * dn, decContext * set)
/* No error is possible. */
/* ------------------------------------------------------------------ */
decNumber *
-decimal128ToNumber (decimal128 * d128, decNumber * dn)
+decimal128ToNumber (const decimal128 * d128, decNumber * dn)
{
uInt msd; /* coefficient MSD */
decimal128 wk; /* working copy, if needed */
@@ -263,7 +263,7 @@ decimal128ToNumber (decimal128 * d128, decNumber * dn)
/* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */
char *
-decimal128ToString (decimal128 * d128, char *string)
+decimal128ToString (const decimal128 * d128, char *string)
{
decNumber dn; /* work */
decimal128ToNumber (d128, &dn);
@@ -272,7 +272,7 @@ decimal128ToString (decimal128 * d128, char *string)
}
char *
-decimal128ToEngString (decimal128 * d128, char *string)
+decimal128ToEngString (const decimal128 * d128, char *string)
{
decNumber dn; /* work */
decimal128ToNumber (d128, &dn);
@@ -321,7 +321,7 @@ decimal128FromString (decimal128 * result, const char *string, decContext * set)
/* ------------------------------------------------------------------ */
/* Also shows sign/cob/expconfields extracted */
void
-decimal128Show (decimal128 * d128)
+decimal128Show (const decimal128 * d128)
{
char buf[DECIMAL128_Bytes * 2 + 1];
Int i, j;
diff --git a/libdecnumber/decimal128.h b/libdecnumber/decimal128.h
index 495b6e3022f..cabe600e113 100644
--- a/libdecnumber/decimal128.h
+++ b/libdecnumber/decimal128.h
@@ -103,11 +103,11 @@ typedef struct
/* String conversions */
decimal128 *decimal128FromString (decimal128 *, const char *, decContext *);
-char *decimal128ToString (decimal128 *, char *);
-char *decimal128ToEngString (decimal128 *, char *);
+char *decimal128ToString (const decimal128 *, char *);
+char *decimal128ToEngString (const decimal128 *, char *);
/* decNumber conversions */
-decimal128 *decimal128FromNumber (decimal128 *, decNumber *, decContext *);
-decNumber *decimal128ToNumber (decimal128 *, decNumber *);
+decimal128 *decimal128FromNumber (decimal128 *, const decNumber *, decContext *);
+decNumber *decimal128ToNumber (const decimal128 *, decNumber *);
#endif
diff --git a/libdecnumber/decimal32.c b/libdecnumber/decimal32.c
index 88f79e9093e..8e4f1ce8ad2 100644
--- a/libdecnumber/decimal32.c
+++ b/libdecnumber/decimal32.c
@@ -38,8 +38,8 @@
#include "decUtility.h" /* utility routines */
#if DECTRACE || DECCHECK
-void decimal32Show (decimal32 *); /* for debug */
-void decNumberShow (decNumber *); /* .. */
+void decimal32Show (const decimal32 *); /* for debug */
+void decNumberShow (const decNumber *); /* .. */
#endif
/* Useful macro */
@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */
/* power of ten, or if the exponent on a zero had to be clamped. */
/* ------------------------------------------------------------------ */
decimal32 *
-decimal32FromNumber (decimal32 * d32, decNumber * dn, decContext * set)
+decimal32FromNumber (decimal32 * d32, const decNumber * dn, decContext * set)
{
uInt status = 0; /* status accumulator */
Int pad = 0; /* coefficient pad digits */
@@ -181,7 +181,7 @@ decimal32FromNumber (decimal32 * d32, decNumber * dn, decContext * set)
/* No error is possible. */
/* ------------------------------------------------------------------ */
decNumber *
-decimal32ToNumber (decimal32 * d32, decNumber * dn)
+decimal32ToNumber (const decimal32 * d32, decNumber * dn)
{
uInt msd; /* coefficient MSD */
decimal32 wk; /* working copy, if needed */
@@ -255,7 +255,7 @@ decimal32ToNumber (decimal32 * d32, decNumber * dn)
/* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */
char *
-decimal32ToString (decimal32 * d32, char *string)
+decimal32ToString (const decimal32 * d32, char *string)
{
decNumber dn; /* work */
decimal32ToNumber (d32, &dn);
@@ -264,7 +264,7 @@ decimal32ToString (decimal32 * d32, char *string)
}
char *
-decimal32ToEngString (decimal32 * d32, char *string)
+decimal32ToEngString (const decimal32 * d32, char *string)
{
decNumber dn; /* work */
decimal32ToNumber (d32, &dn);
@@ -312,7 +312,7 @@ decimal32FromString (decimal32 * result, const char *string, decContext * set)
/* ------------------------------------------------------------------ */
/* Also shows sign/cob/expconfields extracted */
void
-decimal32Show (decimal32 * d32)
+decimal32Show (const decimal32 * d32)
{
char buf[DECIMAL32_Bytes * 2 + 1];
Int i, j;
diff --git a/libdecnumber/decimal32.h b/libdecnumber/decimal32.h
index d00ae5b92d4..f824b58af10 100644
--- a/libdecnumber/decimal32.h
+++ b/libdecnumber/decimal32.h
@@ -93,11 +93,11 @@ typedef struct
/* String conversions. */
decimal32 *decimal32FromString (decimal32 *, const char *, decContext *);
-char *decimal32ToString (decimal32 *, char *);
-char *decimal32ToEngString (decimal32 *, char *);
+char *decimal32ToString (const decimal32 *, char *);
+char *decimal32ToEngString (const decimal32 *, char *);
/* decNumber conversions. */
-decimal32 *decimal32FromNumber (decimal32 *, decNumber *, decContext *);
-decNumber *decimal32ToNumber (decimal32 *, decNumber *);
+decimal32 *decimal32FromNumber (decimal32 *, const decNumber *, decContext *);
+decNumber *decimal32ToNumber (const decimal32 *, decNumber *);
#endif
diff --git a/libdecnumber/decimal64.c b/libdecnumber/decimal64.c
index 5514d12cc53..8ae6f102920 100644
--- a/libdecnumber/decimal64.c
+++ b/libdecnumber/decimal64.c
@@ -38,8 +38,8 @@
#include "decUtility.h" /* utility routines */
#if DECTRACE || DECCHECK
-void decimal64Show (decimal64 *); /* for debug */
-void decNumberShow (decNumber *); /* .. */
+void decimal64Show (const decimal64 *); /* for debug */
+void decNumberShow (const decNumber *); /* .. */
#endif
/* Useful macro */
@@ -64,7 +64,7 @@ void decNumberShow (decNumber *); /* .. */
/* power of ten, or if the exponent on a zero had to be clamped. */
/* ------------------------------------------------------------------ */
decimal64 *
-decimal64FromNumber (decimal64 * d64, decNumber * dn, decContext * set)
+decimal64FromNumber (decimal64 * d64, const decNumber * dn, decContext * set)
{
uInt status = 0; /* status accumulator */
Int pad = 0; /* coefficient pad digits */
@@ -180,7 +180,7 @@ decimal64FromNumber (decimal64 * d64, decNumber * dn, decContext * set)
/* No error is possible. */
/* ------------------------------------------------------------------ */
decNumber *
-decimal64ToNumber (decimal64 * d64, decNumber * dn)
+decimal64ToNumber (const decimal64 * d64, decNumber * dn)
{
uInt msd; /* coefficient MSD */
decimal64 wk; /* working copy, if needed */
@@ -254,7 +254,7 @@ decimal64ToNumber (decimal64 * d64, decNumber * dn)
/* No error is possible, and no status can be set. */
/* ------------------------------------------------------------------ */
char *
-decimal64ToString (decimal64 * d64, char *string)
+decimal64ToString (const decimal64 * d64, char *string)
{
decNumber dn; /* work */
decimal64ToNumber (d64, &dn);
@@ -263,7 +263,7 @@ decimal64ToString (decimal64 * d64, char *string)
}
char *
-decimal64ToEngString (decimal64 * d64, char *string)
+decimal64ToEngString (const decimal64 * d64, char *string)
{
decNumber dn; /* work */
decimal64ToNumber (d64, &dn);
@@ -312,7 +312,7 @@ decimal64FromString (decimal64 * result, const char *string, decContext * set)
/* ------------------------------------------------------------------ */
/* Also shows sign/cob/expconfields extracted */
void
-decimal64Show (decimal64 * d64)
+decimal64Show (const decimal64 * d64)
{
char buf[DECIMAL64_Bytes * 2 + 1];
Int i, j;
diff --git a/libdecnumber/decimal64.h b/libdecnumber/decimal64.h
index 7416f549c07..cb7810bbf0e 100644
--- a/libdecnumber/decimal64.h
+++ b/libdecnumber/decimal64.h
@@ -97,11 +97,11 @@ typedef struct
/* String conversions */
decimal64 *decimal64FromString (decimal64 *, const char *, decContext *);
-char *decimal64ToString (decimal64 *, char *);
-char *decimal64ToEngString (decimal64 *, char *);
+char *decimal64ToString (const decimal64 *, char *);
+char *decimal64ToEngString (const decimal64 *, char *);
/* decNumber conversions */
-decimal64 *decimal64FromNumber (decimal64 *, decNumber *, decContext *);
-decNumber *decimal64ToNumber (decimal64 *, decNumber *);
+decimal64 *decimal64FromNumber (decimal64 *, const decNumber *, decContext *);
+decNumber *decimal64ToNumber (const decimal64 *, decNumber *);
#endif