Commit 2533577f by Janis Johnson Committed by Janis Johnson

Makefile.in (libdecnumber_a_OBJS): Remove decUtility.o

2007-09-10  Janis Johnson  <janis187@us.ibm.com>
	    Ben Elliston  <bje@au.ibm.com>

libdecnumber/
	* Makefile.in (libdecnumber_a_OBJS): Remove decUtility.o
	(dependencies): Add Symbols headers.
	* decContext.c: Upgrade to decNumber 3.53.
	* decContext.h: Ditto.
	* decDPD.h: Ditto.
	* decNumber.c: Ditto.
	* decNumber.h: Ditto.
	* decNumberLocal.h: Ditto.
	* decBasic.c: New file from decNumber 3.53.
	* decCommon.c: Ditto.
	* decDouble.c: Ditto.
	* decDouble.h: Ditto.
	* decQuad.c: Ditto.
	* decQuad.h: Ditto.
	* decSingle.c: Ditto.
	* decSingle.h: Ditto.
	* decPacked.c: Ditto.
	* decPacked.h: Ditto.
	* dpd/decimal128.c: Upgrade to decNumber 3.53.
	* dpd/decimal128.h: Ditto.
	* dpd/decimal32.c: Ditto.
	* dpd/decimal32.h: Ditto.
	* dpd/decimal64.c: Ditto.
	* dpd/decimal64.h: Ditto.
	* decLibrary.c (__dec_byte_swap): Remove.
	* decContextSymbols.h: New file.
	* decDoubleSymbols.h: New file.
	* decNumberSymbols.h: New file.
	* decPackedSymbols.h: New file.
	* decQuadSymbols.h: New file.
	* decSingleSymbols.h: New file.
	* decUtility.c: Delete file.
	* decUtility.h: Delete file.
	* bid/decimal128Symbols.h: New file.
	* bid/decimal128Local.h: New file.
	* bid/decimal32Symbols.h: New file.
	* bid/decimal64Symbols.h: New file.
	* bid/host-ieee128.c (__swap128): Remove.
	(__host_to_ieee_128, __ieee_to_host_128): Don't handle endianness.
	* bid/host-ieee32.c (__dec_type_swap): Remove.
	(__host_to_ieee_32, __ieee_to_host_32): Don't handle endianness.
	* bid/host-ieee64.c (__swap64): Remove.
	(__host_to_ieee_64, __ieee_to_host_64): Don't handle endianness.
	* dpd/decimal32Symbols.h: New file.
	* dpd/decimal64Symbols.h: New file.
	* dpd/decimal128Symbols.h: New file.
	* dpd/decimal128Local.h: New file.

libgcc/
	* Makefile.in (dfp-filenames): Remove decUtility, add
	decDouble, decPacked, decQuad, decSingle.

gcc/
	* dfp.c: Include decimal128Local.h; 
	(dfp_byte_swap): Remove.
	(encode_decimal32, decode_decimal32): Don't handle endianness.
	(encode_decimal64, decode_decimal64): Ditto.
	(encode_decimal128, decode_decimal128): Ditto.
	* config/dfp-bit.c (host_to_ieee32, ieee_to_host_32): Ditto.
	(__swap64): Remove.
	(host_to_ieee_64, ieee_to_host_64): Don't handle endianness.
         (__swap128): Remove
	(host_to_ieee_128, ieee_to_host_128): Don't handle endianness.
	* Makefile.in (DECNUM_H): Add decimal128Local.h.

Co-Authored-By: Ben Elliston <bje@au.ibm.com>

From-SVN: r128350
parent bfd9cff5
2007-09-10 Janis Johnson <janis187@us.ibm.com>
Ben Elliston <bje@au.ibm.com>
* dfp.c: Include decimal128Local.h;
(dfp_byte_swap): Remove.
(encode_decimal32, decode_decimal32): Don't handle endianness.
(encode_decimal64, decode_decimal64): Ditto.
(encode_decimal128, decode_decimal128): Ditto.
* config/dfp-bit.c (host_to_ieee32, ieee_to_host_32): Ditto.
(__swap64): Remove.
(host_to_ieee_64, ieee_to_host_64): Don't handle endianness.
(__swap128): Remove
(host_to_ieee_128, ieee_to_host_128): Don't handle endianness.
* Makefile.in (DECNUM_H): Add decimal128Local.h.
2007-09-10 David Daney <ddaney@avtrex.com>
* config/mips/mips.md (UNSPEC_MEMORY_BARRIER): New entry in
......@@ -815,7 +815,8 @@ PREDICT_H = predict.h predict.def
CPPLIB_H = $(srcdir)/../libcpp/include/line-map.h \
$(srcdir)/../libcpp/include/cpplib.h
DECNUM_H = $(DECNUM)/decContext.h $(DECNUM)/decDPD.h $(DECNUM)/decNumber.h \
$(DECNUMFMT)/decimal32.h $(DECNUMFMT)/decimal64.h $(DECNUMFMT)/decimal128.h
$(DECNUMFMT)/decimal32.h $(DECNUMFMT)/decimal64.h \
$(DECNUMFMT)/decimal128.h $(DECNUMFMT)/decimal128Local.h
MKDEPS_H = $(srcdir)/../libcpp/include/mkdeps.h
SYMTAB_H = $(srcdir)/../libcpp/include/symtab.h
CPP_ID_DATA_H = $(CPPLIB_H) $(srcdir)/../libcpp/include/cpp-id-data.h
......
......@@ -70,8 +70,6 @@ typedef decNumber* (*dfp_unary_func)
/* A pointer to a binary decNumber operation. */
typedef decNumber* (*dfp_binary_func)
(decNumber *, const decNumber *, const decNumber *, decContext *);
extern uint32_t __dec_byte_swap (uint32_t);
/* Unary operations. */
......@@ -190,101 +188,41 @@ dfp_compare_op (dfp_binary_func op, DFP_C_TYPE arg_a, DFP_C_TYPE arg_b)
void
__host_to_ieee_32 (_Decimal32 in, decimal32 *out)
{
uint32_t t;
if (!LIBGCC2_FLOAT_WORDS_BIG_ENDIAN)
{
memcpy (&t, &in, 4);
t = __dec_byte_swap (t);
memcpy (out, &t, 4);
}
else
memcpy (out, &in, 4);
memcpy (out, &in, 4);
}
void
__ieee_to_host_32 (decimal32 in, _Decimal32 *out)
{
uint32_t t;
if (!LIBGCC2_FLOAT_WORDS_BIG_ENDIAN)
{
memcpy (&t, &in, 4);
t = __dec_byte_swap (t);
memcpy (out, &t, 4);
}
else
memcpy (out, &in, 4);
memcpy (out, &in, 4);
}
#endif /* L_conv_sd */
#if defined(L_conv_dd)
static void
__swap64 (char *src, char *dst)
{
uint32_t t1, t2;
if (!LIBGCC2_FLOAT_WORDS_BIG_ENDIAN)
{
memcpy (&t1, src, 4);
memcpy (&t2, src + 4, 4);
t1 = __dec_byte_swap (t1);
t2 = __dec_byte_swap (t2);
memcpy (dst, &t2, 4);
memcpy (dst + 4, &t1, 4);
}
else
memcpy (dst, src, 8);
}
void
__host_to_ieee_64 (_Decimal64 in, decimal64 *out)
{
__swap64 ((char *) &in, (char *) out);
memcpy (out, &in, 8);
}
void
__ieee_to_host_64 (decimal64 in, _Decimal64 *out)
{
__swap64 ((char *) &in, (char *) out);
memcpy (out, &in, 8);
}
#endif /* L_conv_dd */
#if defined(L_conv_td)
static void
__swap128 (char *src, char *dst)
{
uint32_t t1, t2, t3, t4;
if (!LIBGCC2_FLOAT_WORDS_BIG_ENDIAN)
{
memcpy (&t1, src, 4);
memcpy (&t2, src + 4, 4);
memcpy (&t3, src + 8, 4);
memcpy (&t4, src + 12, 4);
t1 = __dec_byte_swap (t1);
t2 = __dec_byte_swap (t2);
t3 = __dec_byte_swap (t3);
t4 = __dec_byte_swap (t4);
memcpy (dst, &t4, 4);
memcpy (dst + 4, &t3, 4);
memcpy (dst + 8, &t2, 4);
memcpy (dst + 12, &t1, 4);
}
else
memcpy (dst, src, 16);
}
void
__host_to_ieee_128 (_Decimal128 in, decimal128 *out)
{
__swap128 ((char *) &in, (char *) out);
memcpy (out, &in, 16);
}
void
__ieee_to_host_128 (decimal128 in, _Decimal128 *out)
{
__swap128 ((char *) &in, (char *) out);
memcpy (out, &in, 16);
}
#endif /* L_conv_td */
......
......@@ -31,29 +31,11 @@ along with GCC; see the file COPYING3. If not see
decNumber structure is large enough to hold decimal128 digits. */
#include "decimal128.h"
#include "decimal128Local.h"
#include "decimal64.h"
#include "decimal32.h"
#include "decNumber.h"
static uint32_t
dfp_byte_swap (uint32_t in)
{
uint32_t out = 0;
unsigned char *p = (unsigned char *) &out;
union {
uint32_t i;
unsigned char b[4];
} u;
u.i = in;
p[0] = u.b[3];
p[1] = u.b[2];
p[2] = u.b[1];
p[3] = u.b[0];
return out;
}
/* Initialize R (a real with the decimal flag set) from DN. Can
utilize status passed in via CONTEXT, if a previous operation had
interesting status. */
......@@ -155,10 +137,7 @@ encode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decimal_to_decnumber (r, &dn);
decimal32FromNumber (&d32, &dn, &set);
if (FLOAT_WORDS_BIG_ENDIAN)
buf[0] = *(uint32_t *) d32.bytes;
else
buf[0] = dfp_byte_swap (*(uint32_t *) d32.bytes);
buf[0] = *(uint32_t *) d32.bytes;
}
/* Decode an IEEE 754R decimal32 type into a real. */
......@@ -174,10 +153,7 @@ decode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decContextDefault (&set, DEC_INIT_DECIMAL128);
set.traps = 0;
if (FLOAT_WORDS_BIG_ENDIAN)
*((uint32_t *) d32.bytes) = (uint32_t) buf[0];
else
*((uint32_t *) d32.bytes) = dfp_byte_swap ((uint32_t) buf[0]);
*((uint32_t *) d32.bytes) = (uint32_t) buf[0];
decimal32ToNumber (&d32, &dn);
decimal_from_decnumber (r, &dn, &set);
......@@ -199,16 +175,8 @@ encode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decimal_to_decnumber (r, &dn);
decimal64FromNumber (&d64, &dn, &set);
if (FLOAT_WORDS_BIG_ENDIAN)
{
buf[0] = *(uint32_t *) &d64.bytes[0];
buf[1] = *(uint32_t *) &d64.bytes[4];
}
else
{
buf[1] = dfp_byte_swap (*(uint32_t *) &d64.bytes[0]);
buf[0] = dfp_byte_swap (*(uint32_t *) &d64.bytes[4]);
}
buf[0] = *(uint32_t *) &d64.bytes[0];
buf[1] = *(uint32_t *) &d64.bytes[4];
}
/* Decode an IEEE 754R decimal64 type into a real. */
......@@ -224,16 +192,8 @@ decode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decContextDefault (&set, DEC_INIT_DECIMAL128);
set.traps = 0;
if (FLOAT_WORDS_BIG_ENDIAN)
{
*((uint32_t *) &d64.bytes[0]) = (uint32_t) buf[0];
*((uint32_t *) &d64.bytes[4]) = (uint32_t) buf[1];
}
else
{
*((uint32_t *) &d64.bytes[0]) = dfp_byte_swap ((uint32_t) buf[1]);
*((uint32_t *) &d64.bytes[4]) = dfp_byte_swap ((uint32_t) buf[0]);
}
*((uint32_t *) &d64.bytes[0]) = (uint32_t) buf[0];
*((uint32_t *) &d64.bytes[4]) = (uint32_t) buf[1];
decimal64ToNumber (&d64, &dn);
decimal_from_decnumber (r, &dn, &set);
......@@ -255,20 +215,10 @@ encode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decimal_to_decnumber (r, &dn);
decimal128FromNumber (&d128, &dn, &set);
if (FLOAT_WORDS_BIG_ENDIAN)
{
buf[0] = *(uint32_t *) &d128.bytes[0];
buf[1] = *(uint32_t *) &d128.bytes[4];
buf[2] = *(uint32_t *) &d128.bytes[8];
buf[3] = *(uint32_t *) &d128.bytes[12];
}
else
{
buf[0] = dfp_byte_swap (*(uint32_t *) &d128.bytes[12]);
buf[1] = dfp_byte_swap (*(uint32_t *) &d128.bytes[8]);
buf[2] = dfp_byte_swap (*(uint32_t *) &d128.bytes[4]);
buf[3] = dfp_byte_swap (*(uint32_t *) &d128.bytes[0]);
}
buf[0] = *(uint32_t *) &d128.bytes[0];
buf[1] = *(uint32_t *) &d128.bytes[4];
buf[2] = *(uint32_t *) &d128.bytes[8];
buf[3] = *(uint32_t *) &d128.bytes[12];
}
/* Decode an IEEE 754R decimal128 type into a real. */
......@@ -284,20 +234,10 @@ decode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decContextDefault (&set, DEC_INIT_DECIMAL128);
set.traps = 0;
if (FLOAT_WORDS_BIG_ENDIAN)
{
*((uint32_t *) &d128.bytes[0]) = (uint32_t) buf[0];
*((uint32_t *) &d128.bytes[4]) = (uint32_t) buf[1];
*((uint32_t *) &d128.bytes[8]) = (uint32_t) buf[2];
*((uint32_t *) &d128.bytes[12]) = (uint32_t) buf[3];
}
else
{
*((uint32_t *) &d128.bytes[0]) = dfp_byte_swap ((uint32_t) buf[3]);
*((uint32_t *) &d128.bytes[4]) = dfp_byte_swap ((uint32_t) buf[2]);
*((uint32_t *) &d128.bytes[8]) = dfp_byte_swap ((uint32_t) buf[1]);
*((uint32_t *) &d128.bytes[12]) = dfp_byte_swap ((uint32_t) buf[0]);
}
*((uint32_t *) &d128.bytes[0]) = (uint32_t) buf[0];
*((uint32_t *) &d128.bytes[4]) = (uint32_t) buf[1];
*((uint32_t *) &d128.bytes[8]) = (uint32_t) buf[2];
*((uint32_t *) &d128.bytes[12]) = (uint32_t) buf[3];
decimal128ToNumber (&d128, &dn);
decimal_from_decnumber (r, &dn, &set);
......
2007-09-10 Janis Johnson <janis187@us.ibm.com>
Ben Elliston <bje@au.ibm.com>
* Makefile.in (libdecnumber_a_OBJS): Remove decUtility.o
(dependencies): Add Symbols headers.
* decContext.c: Upgrade to decNumber 3.53.
* decContext.h: Ditto.
* decDPD.h: Ditto.
* decNumber.c: Ditto.
* decNumber.h: Ditto.
* decNumberLocal.h: Ditto.
* decBasic.c: New file from decNumber 3.53.
* decCommon.c: Ditto.
* decDouble.c: Ditto.
* decDouble.h: Ditto.
* decQuad.c: Ditto.
* decQuad.h: Ditto.
* decSingle.c: Ditto.
* decSingle.h: Ditto.
* decPacked.c: Ditto.
* decPacked.h: Ditto.
* dpd/decimal128.c: Upgrade to decNumber 3.53.
* dpd/decimal128.h: Ditto.
* dpd/decimal32.c: Ditto.
* dpd/decimal32.h: Ditto.
* dpd/decimal64.c: Ditto.
* dpd/decimal64.h: Ditto.
* decLibrary.c (__dec_byte_swap): Remove.
* decContextSymbols.h: New file.
* decDoubleSymbols.h: New file.
* decNumberSymbols.h: New file.
* decPackedSymbols.h: New file.
* decQuadSymbols.h: New file.
* decSingleSymbols.h: New file.
* decUtility.c: Delete file.
* decUtility.h: Delete file.
* bid/decimal128Symbols.h: New file.
* bid/decimal128Local.h: New file.
* bid/decimal32Symbols.h: New file.
* bid/decimal64Symbols.h: New file.
* bid/host-ieee128.c (__swap128): Remove.
(__host_to_ieee_128, __ieee_to_host_128): Don't handle endianness.
* bid/host-ieee32.c (__dec_type_swap): Remove.
(__host_to_ieee_32, __ieee_to_host_32): Don't handle endianness.
* bid/host-ieee64.c (__swap64): Remove.
(__host_to_ieee_64, __ieee_to_host_64): Don't handle endianness.
* dpd/decimal32Symbols.h: New file.
* dpd/decimal64Symbols.h: New file.
* dpd/decimal128Symbols.h: New file.
* dpd/decimal128Local.h: New file.
2007-06-18 Martin Michlmayr <tbm@cyrius.com>
H.J. Lu <hongjiu.lu@intel.com>
......
......@@ -56,7 +56,7 @@ INCLUDES = -I$(srcdir) -I.
ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS)
libdecnumber_a_OBJS = decNumber.o decContext.o decUtility.o \
libdecnumber_a_OBJS = decNumber.o decContext.o \
decimal32.o decimal64.o decimal128.o
ifeq ($(enable_decimal_float),bid)
......@@ -66,7 +66,6 @@ endif
libdecnumber_a_SOURCES = decContext.c decContext.h decDPD.h \
decNumber.c decNumber.h decNumberLocal.h \
decUtility.c decUtility.h \
dpd/decimal128.c dpd/decimal128.h \
dpd/decimal32.c dpd/decimal32.h \
dpd/decimal64.c dpd/decimal64.h \
......@@ -113,19 +112,25 @@ $(srcdir)/config.in: @MAINT@ $(srcdir)/configure
# Dependencies.
decContext.o: decContext.c decContext.h decNumberLocal.h
decNumber.o: decNumber.c decNumber.h decContext.h decNumberLocal.h
decContext.o: decContext.c decContext.h decNumberLocal.h \
decContextSymbols.h
decNumber.o: decNumber.c decNumber.h decContext.h decNumberLocal.h \
decNumberSymbols.h
decimal32.o: $(enable_decimal_float)/decimal32.c \
$(enable_decimal_float)/decimal32.h \
decNumber.h decContext.h decNumberLocal.h decUtility.h
$(enable_decimal_float)/decimal32Symbols.h \
decNumber.h decContext.h decNumberLocal.h
$(COMPILE) $<
decimal64.o: $(enable_decimal_float)/decimal64.c \
$(enable_decimal_float)/decimal64.h \
decNumber.h decContext.h decNumberLocal.h decUtility.h
$(enable_decimal_float)/decimal64Symbols.h \
decNumber.h decContext.h decNumberLocal.h
$(COMPILE) $<
decimal128.o: $(enable_decimal_float)/decimal128.c \
$(enable_decimal_float)/decimal128.h \
decNumber.h decContext.h decNumberLocal.h decUtility.h
$(enable_decimal_float)/decimal128Symbols.h\
$(enable_decimal_float)/decimal128Local.h\
decNumber.h decContext.h decNumberLocal.h
$(COMPILE) $<
bid2dpd_dpd2bid.o : bid/bid2dpd_dpd2bid.c bid/bid2dpd_dpd2bid.h
$(COMPILE) $<
......
#include "dpd/decimal128Local.h"
#include "dpd/decimal128Symbols.h"
#include "dpd/decimal32Symbols.h"
#include "dpd/decimal64Symbols.h"
......@@ -27,56 +27,22 @@ along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "config.h"
#include "gstdint.h"
#include "bid-dpd.h"
#include "decimal128.h"
extern uint32_t __dec_byte_swap (uint32_t);
void __host_to_ieee_128 (_Decimal128 in, decimal128 *out);
void __ieee_to_host_128 (decimal128 in, _Decimal128 *out);
#ifndef WORDS_BIGENDIAN
#define WORDS_BIGENDIAN 0
#endif
static void
__swap128 (char *src, char *dst)
{
uint32_t t1, t2, t3, t4;
if (!WORDS_BIGENDIAN)
{
memcpy (&t1, src, 4);
memcpy (&t2, src + 4, 4);
memcpy (&t3, src + 8, 4);
memcpy (&t4, src + 12, 4);
t1 = __dec_byte_swap (t1);
t2 = __dec_byte_swap (t2);
t3 = __dec_byte_swap (t3);
t4 = __dec_byte_swap (t4);
memcpy (dst, &t4, 4);
memcpy (dst + 4, &t3, 4);
memcpy (dst + 8, &t2, 4);
memcpy (dst + 12, &t1, 4);
}
else
memcpy (dst, src, 16);
}
void
__host_to_ieee_128 (_Decimal128 in, decimal128 *out)
{
__swap128 ((char *) &in, (char *) out);
memcpy ((char *) out, (char *) &in, 16);
}
void
__ieee_to_host_128 (decimal128 in, _Decimal128 *out)
{
__swap128 ((char *) &in, (char *) out);
memcpy ((char *) out, (char *) &in, 16);
}
......@@ -37,69 +37,21 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
/* The intended way to use this file is to make two copies, add `#define '
to one copy, then compile both copies and add them to libgcc.a. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "config.h"
#include "gstdint.h"
#include "bid-dpd.h"
#include "decimal32.h"
uint32_t __dec_byte_swap (uint32_t);
void __host_to_ieee_32 (_Decimal32 in, decimal32 *out);
void __ieee_to_host_32 (decimal32 in, _Decimal32 *out);
#ifndef WORDS_BIGENDIAN
#define WORDS_BIGENDIAN 0
#endif
uint32_t
__dec_byte_swap (uint32_t in)
{
uint32_t out = 0;
unsigned char *p = (unsigned char *) &out;
union {
uint32_t i;
unsigned char b[4];
} u;
u.i = in;
p[0] = u.b[3];
p[1] = u.b[2];
p[2] = u.b[1];
p[3] = u.b[0];
return out;
}
void
__host_to_ieee_32 (_Decimal32 in, decimal32 *out)
{
uint32_t t;
if (!WORDS_BIGENDIAN)
{
memcpy (&t, &in, 4);
t = __dec_byte_swap (t);
memcpy (out, &t, 4);
}
else
memcpy (out, &in, 4);
memcpy ((char *) out, (char *) &in, 4);
}
void
__ieee_to_host_32 (decimal32 in, _Decimal32 *out)
{
uint32_t t;
if (!WORDS_BIGENDIAN)
{
memcpy (&t, &in, 4);
t = __dec_byte_swap (t);
memcpy (out, &t, 4);
}
else
memcpy (out, &in, 4);
memcpy ((char *) out, (char *) &in, 4);
}
......@@ -37,50 +37,21 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
/* The intended way to use this file is to make two copies, add `#define '
to one copy, then compile both copies and add them to libgcc.a. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "config.h"
#include "gstdint.h"
#include "bid-dpd.h"
#include "decimal64.h"
uint32_t __dec_byte_swap (uint32_t);
void __host_to_ieee_64 (_Decimal64 in, decimal64 *out);
void __ieee_to_host_64 (decimal64 in, _Decimal64 *out);
#ifndef WORDS_BIGENDIAN
#define WORDS_BIGENDIAN 0
#endif
static void
__swap64 (char *src, char *dst)
{
uint32_t t1, t2;
if (!WORDS_BIGENDIAN)
{
memcpy (&t1, src, 4);
memcpy (&t2, src + 4, 4);
t1 = __dec_byte_swap (t1);
t2 = __dec_byte_swap (t2);
memcpy (dst, &t2, 4);
memcpy (dst + 4, &t1, 4);
}
else
memcpy (dst, src, 8);
}
void
__host_to_ieee_64 (_Decimal64 in, decimal64 *out)
{
__swap64 ((char *) &in, (char *) out);
memcpy ((char *) out, (char *) &in, 8);
}
void
__ieee_to_host_64 (decimal64 in, _Decimal64 *out)
{
__swap64 ((char *) &in, (char *) out);
memcpy ((char *) out, (char *) &in, 8);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
#if !defined(DECCONTEXTSYMBOLS)
#define DECCONTEXTSYMBOLS
#ifdef IN_LIBGCC2
#define decContextClearStatus __decContextClearStatus
#define decContextDefault __decContextDefault
#define decContextGetRounding __decContextGetRounding
#define decContextGetStatus __decContextGetStatus
#define decContextRestoreStatus __decContextRestoreStatus
#define decContextSaveStatus __decContextSaveStatus
#define decContextSetRounding __decContextSetRounding
#define decContextSetStatus __decContextSetStatus
#define decContextSetStatusFromString __decContextSetStatusFromString
#define decContextSetStatusFromStringQuiet __decContextSetStatusFromStringQuiet
#define decContextSetStatusQuiet __decContextSetStatusQuiet
#define decContextStatusToString __decContextStatusToString
#define decContextTestSavedStatus __decContextTestSavedStatus
#define decContextTestStatus __decContextTestStatus
#define decContextZeroStatus __decContextZeroStatus
#endif
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
/* decDouble module for the decNumber C Library.
Copyright (C) 2007 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
In addition to the permissions in the GNU General Public License,
the Free Software Foundation gives you unlimited permission to link
the compiled version of this file into combinations with other
programs, and to distribute those combinations without any
restriction coming from the use of this file. (The General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into a combine executable.)
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* ------------------------------------------------------------------ */
/* decDouble.c -- decDouble operations module */
/* ------------------------------------------------------------------ */
/* This module comprises decDouble operations (including conversions) */
/* ------------------------------------------------------------------ */
#include "decContext.h" /* public includes */
#include "decDouble.h" /* .. */
/* Constant mappings for shared code */
#define DECPMAX DECDOUBLE_Pmax
#define DECEMIN DECDOUBLE_Emin
#define DECEMAX DECDOUBLE_Emax
#define DECEMAXD DECDOUBLE_EmaxD
#define DECBYTES DECDOUBLE_Bytes
#define DECSTRING DECDOUBLE_String
#define DECECONL DECDOUBLE_EconL
#define DECBIAS DECDOUBLE_Bias
#define DECLETS DECDOUBLE_Declets
#define DECQTINY (-DECDOUBLE_Bias)
/* parameters of next-wider format */
#define DECWBYTES DECQUAD_Bytes
#define DECWPMAX DECQUAD_Pmax
#define DECWECONL DECQUAD_EconL
#define DECWBIAS DECQUAD_Bias
/* Type and function mappings for shared code */
#define decFloat decDouble /* Type name */
#define decFloatWider decQuad /* Type name */
/* Utilities and conversions (binary results, extractors, etc.) */
#define decFloatFromBCD decDoubleFromBCD
#define decFloatFromInt32 decDoubleFromInt32
#define decFloatFromPacked decDoubleFromPacked
#define decFloatFromString decDoubleFromString
#define decFloatFromUInt32 decDoubleFromUInt32
#define decFloatFromWider decDoubleFromWider
#define decFloatGetCoefficient decDoubleGetCoefficient
#define decFloatGetExponent decDoubleGetExponent
#define decFloatSetCoefficient decDoubleSetCoefficient
#define decFloatSetExponent decDoubleSetExponent
#define decFloatShow decDoubleShow
#define decFloatToBCD decDoubleToBCD
#define decFloatToEngString decDoubleToEngString
#define decFloatToInt32 decDoubleToInt32
#define decFloatToInt32Exact decDoubleToInt32Exact
#define decFloatToPacked decDoubleToPacked
#define decFloatToString decDoubleToString
#define decFloatToUInt32 decDoubleToUInt32
#define decFloatToUInt32Exact decDoubleToUInt32Exact
#define decFloatToWider decDoubleToWider
#define decFloatZero decDoubleZero
/* Computational (result is a decFloat) */
#define decFloatAbs decDoubleAbs
#define decFloatAdd decDoubleAdd
#define decFloatAnd decDoubleAnd
#define decFloatDivide decDoubleDivide
#define decFloatDivideInteger decDoubleDivideInteger
#define decFloatFMA decDoubleFMA
#define decFloatInvert decDoubleInvert
#define decFloatLogB decDoubleLogB
#define decFloatMax decDoubleMax
#define decFloatMaxMag decDoubleMaxMag
#define decFloatMin decDoubleMin
#define decFloatMinMag decDoubleMinMag
#define decFloatMinus decDoubleMinus
#define decFloatMultiply decDoubleMultiply
#define decFloatNextMinus decDoubleNextMinus
#define decFloatNextPlus decDoubleNextPlus
#define decFloatNextToward decDoubleNextToward
#define decFloatOr decDoubleOr
#define decFloatPlus decDoublePlus
#define decFloatQuantize decDoubleQuantize
#define decFloatReduce decDoubleReduce
#define decFloatRemainder decDoubleRemainder
#define decFloatRemainderNear decDoubleRemainderNear
#define decFloatRotate decDoubleRotate
#define decFloatScaleB decDoubleScaleB
#define decFloatShift decDoubleShift
#define decFloatSubtract decDoubleSubtract
#define decFloatToIntegralValue decDoubleToIntegralValue
#define decFloatToIntegralExact decDoubleToIntegralExact
#define decFloatXor decDoubleXor
/* Comparisons */
#define decFloatCompare decDoubleCompare
#define decFloatCompareSignal decDoubleCompareSignal
#define decFloatCompareTotal decDoubleCompareTotal
#define decFloatCompareTotalMag decDoubleCompareTotalMag
/* Copies */
#define decFloatCanonical decDoubleCanonical
#define decFloatCopy decDoubleCopy
#define decFloatCopyAbs decDoubleCopyAbs
#define decFloatCopyNegate decDoubleCopyNegate
#define decFloatCopySign decDoubleCopySign
/* Non-computational */
#define decFloatClass decDoubleClass
#define decFloatClassString decDoubleClassString
#define decFloatDigits decDoubleDigits
#define decFloatIsCanonical decDoubleIsCanonical
#define decFloatIsFinite decDoubleIsFinite
#define decFloatIsInfinite decDoubleIsInfinite
#define decFloatIsInteger decDoubleIsInteger
#define decFloatIsNaN decDoubleIsNaN
#define decFloatIsNormal decDoubleIsNormal
#define decFloatIsSignaling decDoubleIsSignaling
#define decFloatIsSignalling decDoubleIsSignalling
#define decFloatIsSigned decDoubleIsSigned
#define decFloatIsSubnormal decDoubleIsSubnormal
#define decFloatIsZero decDoubleIsZero
#define decFloatRadix decDoubleRadix
#define decFloatSameQuantum decDoubleSameQuantum
#define decFloatVersion decDoubleVersion
#include "decNumberLocal.h" /* local includes (need DECPMAX) */
#include "decCommon.c" /* non-arithmetic decFloat routines */
#include "decBasic.c" /* basic formats routines */
/* Below here will move to shared file as completed */
#if !defined(DECDOUBLESYMBOLS)
#define DECDOUBLESYMBOLS
#ifdef IN_LIBGCC2
#define decDoubleAbs __decDoubleAbs
#define decDoubleAdd __decDoubleAdd
#define decDoubleAnd __decDoubleAnd
#define decDoubleCanonical __decDoubleCanonical
#define decDoubleClass __decDoubleClass
#define decDoubleClassString __decDoubleClassString
#define decDoubleCompare __decDoubleCompare
#define decDoubleCompareSignal __decDoubleCompareSignal
#define decDoubleCompareTotal __decDoubleCompareTotal
#define decDoubleCompareTotalMag __decDoubleCompareTotalMag
#define decDoubleCopy __decDoubleCopy
#define decDoubleCopyAbs __decDoubleCopyAbs
#define decDoubleCopyNegate __decDoubleCopyNegate
#define decDoubleCopySign __decDoubleCopySign
#define decDoubleDigits __decDoubleDigits
#define decDoubleDivide __decDoubleDivide
#define decDoubleDivideInteger __decDoubleDivideInteger
#define decDoubleFMA __decDoubleFMA
#define decDoubleFromBCD __decDoubleFromBCD
#define decDoubleFromInt32 __decDoubleFromInt32
#define decDoubleFromPacked __decDoubleFromPacked
#define decDoubleFromString __decDoubleFromString
#define decDoubleFromUInt32 __decDoubleFromUInt32
#define decDoubleFromWider __decDoubleFromWider
#define decDoubleGetCoefficient __decDoubleGetCoefficient
#define decDoubleGetExponent __decDoubleGetExponent
#define decDoubleInvert __decDoubleInvert
#define decDoubleIsCanonical __decDoubleIsCanonical
#define decDoubleIsFinite __decDoubleIsFinite
#define decDoubleIsInfinite __decDoubleIsInfinite
#define decDoubleIsInteger __decDoubleIsInteger
#define decDoubleIsNaN __decDoubleIsNaN
#define decDoubleIsNormal __decDoubleIsNormal
#define decDoubleIsSignaling __decDoubleIsSignaling
#define decDoubleIsSignalling __decDoubleIsSignalling
#define decDoubleIsSigned __decDoubleIsSigned
#define decDoubleIsSubnormal __decDoubleIsSubnormal
#define decDoubleIsZero __decDoubleIsZero
#define decDoubleLogB __decDoubleLogB
#define decDoubleMax __decDoubleMax
#define decDoubleMaxMag __decDoubleMaxMag
#define decDoubleMin __decDoubleMin
#define decDoubleMinMag __decDoubleMinMag
#define decDoubleMinus __decDoubleMinus
#define decDoubleMultiply __decDoubleMultiply
#define decDoubleNextMinus __decDoubleNextMinus
#define decDoubleNextPlus __decDoubleNextPlus
#define decDoubleNextToward __decDoubleNextToward
#define decDoubleOr __decDoubleOr
#define decDoublePlus __decDoublePlus
#define decDoubleQuantize __decDoubleQuantize
#define decDoubleRadix __decDoubleRadix
#define decDoubleReduce __decDoubleReduce
#define decDoubleRemainder __decDoubleRemainder
#define decDoubleRemainderNear __decDoubleRemainderNear
#define decDoubleRotate __decDoubleRotate
#define decDoubleSameQuantum __decDoubleSameQuantum
#define decDoubleScaleB __decDoubleScaleB
#define decDoubleSetCoefficient __decDoubleSetCoefficient
#define decDoubleSetExponent __decDoubleSetExponent
#define decDoubleShift __decDoubleShift
#define decDoubleShow __decDoubleShow
#define decDoubleSubtract __decDoubleSubtract
#define decDoubleToBCD __decDoubleToBCD
#define decDoubleToEngString __decDoubleToEngString
#define decDoubleToInt32 __decDoubleToInt32
#define decDoubleToInt32Exact __decDoubleToInt32Exact
#define decDoubleToIntegralExact __decDoubleToIntegralExact
#define decDoubleToIntegralValue __decDoubleToIntegralValue
#define decDoubleToPacked __decDoubleToPacked
#define decDoubleToString __decDoubleToString
#define decDoubleToUInt32 __decDoubleToUInt32
#define decDoubleToUInt32Exact __decDoubleToUInt32Exact
#define decDoubleToWider __decDoubleToWider
#define decDoubleVersion __decDoubleVersion
#define decDoubleXor __decDoubleXor
#define decDoubleZero __decDoubleZero
#endif
#endif
......@@ -74,22 +74,3 @@ isinfd128 (_Decimal128 arg)
decimal128ToNumber (&d128, &dn);
return (decNumberIsInfinite (&dn));
}
uint32_t
__dec_byte_swap (uint32_t in)
{
uint32_t out = 0;
unsigned char *p = (unsigned char *) &out;
union {
uint32_t i;
unsigned char b[4];
} u;
u.i = in;
p[0] = u.b[3];
p[1] = u.b[2];
p[2] = u.b[1];
p[3] = u.b[0];
return out;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
#if !defined(DECNUMBERSYMBOLS)
#define DECNUMBERSYMBOLS
#ifdef IN_LIBGCC2
#define decNumberAbs __decNumberAbs
#define decNumberAdd __decNumberAdd
#define decNumberAnd __decNumberAnd
#define decNumberClass __decNumberClass
#define decNumberClassToString __decNumberClassToString
#define decNumberCompare __decNumberCompare
#define decNumberCompareSignal __decNumberCompareSignal
#define decNumberCompareTotal __decNumberCompareTotal
#define decNumberCompareTotalMag __decNumberCompareTotalMag
#define decNumberCopy __decNumberCopy
#define decNumberCopyAbs __decNumberCopyAbs
#define decNumberCopyNegate __decNumberCopyNegate
#define decNumberCopySign __decNumberCopySign
#define decNumberDivide __decNumberDivide
#define decNumberDivideInteger __decNumberDivideInteger
#define decNumberExp __decNumberExp
#define decNumberFMA __decNumberFMA
#define decNumberFromInt32 __decNumberFromInt32
#define decNumberFromString __decNumberFromString
#define decNumberFromUInt32 __decNumberFromUInt32
#define decNumberGetBCD __decNumberGetBCD
#define decNumberInvert __decNumberInvert
#define decNumberIsNormal __decNumberIsNormal
#define decNumberIsSubnormal __decNumberIsSubnormal
#define decNumberLn __decNumberLn
#define decNumberLog10 __decNumberLog10
#define decNumberLogB __decNumberLogB
#define decNumberMax __decNumberMax
#define decNumberMaxMag __decNumberMaxMag
#define decNumberMin __decNumberMin
#define decNumberMinMag __decNumberMinMag
#define decNumberMinus __decNumberMinus
#define decNumberMultiply __decNumberMultiply
#define decNumberNextMinus __decNumberNextMinus
#define decNumberNextPlus __decNumberNextPlus
#define decNumberNextToward __decNumberNextToward
#define decNumberNormalize __decNumberNormalize
#define decNumberOr __decNumberOr
#define decNumberPlus __decNumberPlus
#define decNumberPower __decNumberPower
#define decNumberQuantize __decNumberQuantize
#define decNumberReduce __decNumberReduce
#define decNumberRemainder __decNumberRemainder
#define decNumberRemainderNear __decNumberRemainderNear
#define decNumberRescale __decNumberRescale
#define decNumberRotate __decNumberRotate
#define decNumberSameQuantum __decNumberSameQuantum
#define decNumberScaleB __decNumberScaleB
#define decNumberSetBCD __decNumberSetBCD
#define decNumberShift __decNumberShift
#define decNumberSquareRoot __decNumberSquareRoot
#define decNumberSubtract __decNumberSubtract
#define decNumberToEngString __decNumberToEngString
#define decNumberToInt32 __decNumberToInt32
#define decNumberToIntegralExact __decNumberToIntegralExact
#define decNumberToIntegralValue __decNumberToIntegralValue
#define decNumberToString __decNumberToString
#define decNumberToUInt32 __decNumberToUInt32
#define decNumberTrim __decNumberTrim
#define decNumberVersion __decNumberVersion
#define decNumberXor __decNumberXor
#define decNumberZero __decNumberZero
#endif
#endif
/* Packed decimal conversion module for the decNumber C Library.
Copyright (C) 2007 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
In addition to the permissions in the GNU General Public License,
the Free Software Foundation gives you unlimited permission to link
the compiled version of this file into combinations with other
programs, and to distribute those combinations without any
restriction coming from the use of this file. (The General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into a combine executable.)
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* ------------------------------------------------------------------ */
/* Packed Decimal conversion module */
/* ------------------------------------------------------------------ */
/* This module comprises the routines for Packed Decimal format */
/* numbers. Conversions are supplied to and from decNumber, which in */
/* turn supports: */
/* conversions to and from string */
/* arithmetic routines */
/* utilities. */
/* Conversions from decNumber to and from densely packed decimal */
/* formats are provided by the decimal32 through decimal128 modules. */
/* ------------------------------------------------------------------ */
#include <string.h> /* for NULL */
#include "decNumber.h" /* base number library */
#include "decPacked.h" /* packed decimal */
#include "decNumberLocal.h" /* decNumber local types, etc. */
/* ------------------------------------------------------------------ */
/* decPackedFromNumber -- convert decNumber to BCD Packed Decimal */
/* */
/* bcd is the BCD bytes */
/* length is the length of the BCD array */
/* scale is the scale result */
/* dn is the decNumber */
/* returns bcd, or NULL if error */
/* */
/* The number is converted to a BCD packed decimal byte array, */
/* right aligned in the bcd array, whose length is indicated by the */
/* second parameter. The final 4-bit nibble in the array will be a */
/* sign nibble, C (1100) for + and D (1101) for -. Unused bytes and */
/* nibbles to the left of the number are set to 0. */
/* */
/* scale is set to the scale of the number (this is the exponent, */
/* negated). To force the number to a specified scale, first use the */
/* decNumberRescale routine, which will round and change the exponent */
/* as necessary. */
/* */
/* If there is an error (that is, the decNumber has too many digits */
/* to fit in length bytes, or it is a NaN or Infinity), NULL is */
/* returned and the bcd and scale results are unchanged. Otherwise */
/* bcd is returned. */
/* ------------------------------------------------------------------ */
uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale,
const decNumber *dn) {
const Unit *up=dn->lsu; /* Unit array pointer */
uByte obyte, *out; /* current output byte, and where it goes */
Int indigs=dn->digits; /* digits processed */
uInt cut=DECDPUN; /* downcounter per Unit */
uInt u=*up; /* work */
uInt nib; /* .. */
#if DECDPUN<=4
uInt temp; /* .. */
#endif
if (dn->digits>length*2-1 /* too long .. */
||(dn->bits & DECSPECIAL)) return NULL; /* .. or special -- hopeless */
if (dn->bits&DECNEG) obyte=DECPMINUS; /* set the sign .. */
else obyte=DECPPLUS;
*scale=-dn->exponent; /* .. and scale */
/* loop from lowest (rightmost) byte */
out=bcd+length-1; /* -> final byte */
for (; out>=bcd; out--) {
if (indigs>0) {
if (cut==0) {
up++;
u=*up;
cut=DECDPUN;
}
#if DECDPUN<=4
temp=(u*6554)>>16; /* fast /10 */
nib=u-X10(temp);
u=temp;
#else
nib=u%10; /* cannot use *6554 trick :-( */
u=u/10;
#endif
obyte|=(nib<<4);
indigs--;
cut--;
}
*out=obyte;
obyte=0; /* assume 0 */
if (indigs>0) {
if (cut==0) {
up++;
u=*up;
cut=DECDPUN;
}
#if DECDPUN<=4
temp=(u*6554)>>16; /* as above */
obyte=(uByte)(u-X10(temp));
u=temp;
#else
obyte=(uByte)(u%10);
u=u/10;
#endif
indigs--;
cut--;
}
} /* loop */
return bcd;
} /* decPackedFromNumber */
/* ------------------------------------------------------------------ */
/* decPackedToNumber -- convert BCD Packed Decimal to a decNumber */
/* */
/* bcd is the BCD bytes */
/* length is the length of the BCD array */
/* scale is the scale associated with the BCD integer */
/* dn is the decNumber [with space for length*2 digits] */
/* returns dn, or NULL if error */
/* */
/* The BCD packed decimal byte array, together with an associated */
/* scale, is converted to a decNumber. The BCD array is assumed full */
/* of digits, and must be ended by a 4-bit sign nibble in the least */
/* significant four bits of the final byte. */
/* */
/* The scale is used (negated) as the exponent of the decNumber. */
/* Note that zeros may have a sign and/or a scale. */
/* */
/* The decNumber structure is assumed to have sufficient space to */
/* hold the converted number (that is, up to length*2-1 digits), so */
/* no error is possible unless the adjusted exponent is out of range, */
/* no sign nibble was found, or a sign nibble was found before the */
/* final nibble. In these error cases, NULL is returned and the */
/* decNumber will be 0. */
/* ------------------------------------------------------------------ */
decNumber * decPackedToNumber(const uByte *bcd, Int length,
const Int *scale, decNumber *dn) {
const uByte *last=bcd+length-1; /* -> last byte */
const uByte *first; /* -> first non-zero byte */
uInt nib; /* work nibble */
Unit *up=dn->lsu; /* output pointer */
Int digits; /* digits count */
Int cut=0; /* phase of output */
decNumberZero(dn); /* default result */
last=&bcd[length-1];
nib=*last & 0x0f; /* get the sign */
if (nib==DECPMINUS || nib==DECPMINUSALT) dn->bits=DECNEG;
else if (nib<=9) return NULL; /* not a sign nibble */
/* skip leading zero bytes [final byte is always non-zero, due to sign] */
for (first=bcd; *first==0;) first++;
digits=(last-first)*2+1; /* calculate digits .. */
if ((*first & 0xf0)==0) digits--; /* adjust for leading zero nibble */
if (digits!=0) dn->digits=digits; /* count of actual digits [if 0, */
/* leave as 1] */
/* check the adjusted exponent; note that scale could be unbounded */
dn->exponent=-*scale; /* set the exponent */
if (*scale>=0) { /* usual case */
if ((dn->digits-*scale-1)<-DECNUMMAXE) { /* underflow */
decNumberZero(dn);
return NULL;}
}
else { /* -ve scale; +ve exponent */
/* need to be careful to avoid wrap, here, also BADINT case */
if ((*scale<-DECNUMMAXE) /* overflow even without digits */
|| ((dn->digits-*scale-1)>DECNUMMAXE)) { /* overflow */
decNumberZero(dn);
return NULL;}
}
if (digits==0) return dn; /* result was zero */
/* copy the digits to the number's units, starting at the lsu */
/* [unrolled] */
for (;;) { /* forever */
/* left nibble first */
nib=(unsigned)(*last & 0xf0)>>4;
/* got a digit, in nib */
if (nib>9) {decNumberZero(dn); return NULL;}
if (cut==0) *up=(Unit)nib;
else *up=(Unit)(*up+nib*DECPOWERS[cut]);
digits--;
if (digits==0) break; /* got them all */
cut++;
if (cut==DECDPUN) {
up++;
cut=0;
}
last--; /* ready for next */
nib=*last & 0x0f; /* get right nibble */
if (nib>9) {decNumberZero(dn); return NULL;}
/* got a digit, in nib */
if (cut==0) *up=(Unit)nib;
else *up=(Unit)(*up+nib*DECPOWERS[cut]);
digits--;
if (digits==0) break; /* got them all */
cut++;
if (cut==DECDPUN) {
up++;
cut=0;
}
} /* forever */
return dn;
} /* decPackedToNumber */
/* Packed decimal conversion module header for the decNumber C Library.
Copyright (C) 2007 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
In addition to the permissions in the GNU General Public License,
the Free Software Foundation gives you unlimited permission to link
the compiled version of this file into combinations with other
programs, and to distribute those combinations without any
restriction coming from the use of this file. (The General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into a combine executable.)
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* ------------------------------------------------------------------ */
/* Packed Decimal conversion module header */
/* ------------------------------------------------------------------ */
#if !defined(DECPACKED)
#define DECPACKED
#define DECPNAME "decPacked" /* Short name */
#define DECPFULLNAME "Packed Decimal conversions" /* Verbose name */
#define DECPAUTHOR "Mike Cowlishaw" /* Who to blame */
#define DECPACKED_DefP 32 /* default precision */
#ifndef DECNUMDIGITS
#define DECNUMDIGITS DECPACKED_DefP /* size if not already defined*/
#endif
#include "decNumber.h" /* context and number library */
/* Sign nibble constants */
#if !defined(DECPPLUSALT)
#define DECPPLUSALT 0x0A /* alternate plus nibble */
#define DECPMINUSALT 0x0B /* alternate minus nibble */
#define DECPPLUS 0x0C /* preferred plus nibble */
#define DECPMINUS 0x0D /* preferred minus nibble */
#define DECPPLUSALT2 0x0E /* alternate plus nibble */
#define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */
#endif
/* ---------------------------------------------------------------- */
/* decPacked public routines */
/* ---------------------------------------------------------------- */
#include "decPackedSymbols.h"
/* Conversions */
uint8_t * decPackedFromNumber(uint8_t *, int32_t, int32_t *,
const decNumber *);
decNumber * decPackedToNumber(const uint8_t *, int32_t, const int32_t *,
decNumber *);
#endif
#if !defined(DECPACKEDSYMBOLS)
#define DECPACKEDSYMBOLS
#ifdef IN_LIBGCC2
#define decPackedFromNumber __decPackedFromNumber
#define decPackedToNumber __decPackedToNumber
#endif
#endif
/* decQuad module for the decNumber C Library.
Copyright (C) 2007 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
In addition to the permissions in the GNU General Public License,
the Free Software Foundation gives you unlimited permission to link
the compiled version of this file into combinations with other
programs, and to distribute those combinations without any
restriction coming from the use of this file. (The General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into a combine executable.)
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* ------------------------------------------------------------------ */
/* decQuad.c -- decQuad operations module */
/* ------------------------------------------------------------------ */
/* This module comprises decQuad operations (including conversions) */
/* ------------------------------------------------------------------ */
#include "decContext.h" /* public includes */
#include "decQuad.h" /* .. */
/* Constant mappings for shared code */
#define DECPMAX DECQUAD_Pmax
#define DECEMIN DECQUAD_Emin
#define DECEMAX DECQUAD_Emax
#define DECEMAXD DECQUAD_EmaxD
#define DECBYTES DECQUAD_Bytes
#define DECSTRING DECQUAD_String
#define DECECONL DECQUAD_EconL
#define DECBIAS DECQUAD_Bias
#define DECLETS DECQUAD_Declets
#define DECQTINY (-DECQUAD_Bias)
/* Type and function mappings for shared code */
#define decFloat decQuad /* Type name */
/* Utilities and conversions (binary results, extractors, etc.) */
#define decFloatFromBCD decQuadFromBCD
#define decFloatFromInt32 decQuadFromInt32
#define decFloatFromPacked decQuadFromPacked
#define decFloatFromString decQuadFromString
#define decFloatFromUInt32 decQuadFromUInt32
#define decFloatFromWider decQuadFromWider
#define decFloatGetCoefficient decQuadGetCoefficient
#define decFloatGetExponent decQuadGetExponent
#define decFloatSetCoefficient decQuadSetCoefficient
#define decFloatSetExponent decQuadSetExponent
#define decFloatShow decQuadShow
#define decFloatToBCD decQuadToBCD
#define decFloatToEngString decQuadToEngString
#define decFloatToInt32 decQuadToInt32
#define decFloatToInt32Exact decQuadToInt32Exact
#define decFloatToPacked decQuadToPacked
#define decFloatToString decQuadToString
#define decFloatToUInt32 decQuadToUInt32
#define decFloatToUInt32Exact decQuadToUInt32Exact
#define decFloatToWider decQuadToWider
#define decFloatZero decQuadZero
/* Computational (result is a decFloat) */
#define decFloatAbs decQuadAbs
#define decFloatAdd decQuadAdd
#define decFloatAnd decQuadAnd
#define decFloatDivide decQuadDivide
#define decFloatDivideInteger decQuadDivideInteger
#define decFloatFMA decQuadFMA
#define decFloatInvert decQuadInvert
#define decFloatLogB decQuadLogB
#define decFloatMax decQuadMax
#define decFloatMaxMag decQuadMaxMag
#define decFloatMin decQuadMin
#define decFloatMinMag decQuadMinMag
#define decFloatMinus decQuadMinus
#define decFloatMultiply decQuadMultiply
#define decFloatNextMinus decQuadNextMinus
#define decFloatNextPlus decQuadNextPlus
#define decFloatNextToward decQuadNextToward
#define decFloatOr decQuadOr
#define decFloatPlus decQuadPlus
#define decFloatQuantize decQuadQuantize
#define decFloatReduce decQuadReduce
#define decFloatRemainder decQuadRemainder
#define decFloatRemainderNear decQuadRemainderNear
#define decFloatRotate decQuadRotate
#define decFloatScaleB decQuadScaleB
#define decFloatShift decQuadShift
#define decFloatSubtract decQuadSubtract
#define decFloatToIntegralValue decQuadToIntegralValue
#define decFloatToIntegralExact decQuadToIntegralExact
#define decFloatXor decQuadXor
/* Comparisons */
#define decFloatCompare decQuadCompare
#define decFloatCompareSignal decQuadCompareSignal
#define decFloatCompareTotal decQuadCompareTotal
#define decFloatCompareTotalMag decQuadCompareTotalMag
/* Copies */
#define decFloatCanonical decQuadCanonical
#define decFloatCopy decQuadCopy
#define decFloatCopyAbs decQuadCopyAbs
#define decFloatCopyNegate decQuadCopyNegate
#define decFloatCopySign decQuadCopySign
/* Non-computational */
#define decFloatClass decQuadClass
#define decFloatClassString decQuadClassString
#define decFloatDigits decQuadDigits
#define decFloatIsCanonical decQuadIsCanonical
#define decFloatIsFinite decQuadIsFinite
#define decFloatIsInfinite decQuadIsInfinite
#define decFloatIsInteger decQuadIsInteger
#define decFloatIsNaN decQuadIsNaN
#define decFloatIsNormal decQuadIsNormal
#define decFloatIsSignaling decQuadIsSignaling
#define decFloatIsSignalling decQuadIsSignalling
#define decFloatIsSigned decQuadIsSigned
#define decFloatIsSubnormal decQuadIsSubnormal
#define decFloatIsZero decQuadIsZero
#define decFloatRadix decQuadRadix
#define decFloatSameQuantum decQuadSameQuantum
#define decFloatVersion decQuadVersion
#include "decNumberLocal.h" /* local includes (need DECPMAX) */
#include "decCommon.c" /* non-arithmetic decFloat routines */
#include "decBasic.c" /* basic formats routines */
#if !defined(DECQUADSYMBOLS)
#define DECQUADSYMBOLS
#ifdef IN_LIBGCC2
#define decQuadAbs __decQuadAbs
#define decQuadAdd __decQuadAdd
#define decQuadAnd __decQuadAnd
#define decQuadCanonical __decQuadCanonical
#define decQuadClass __decQuadClass
#define decQuadClassString __decQuadClassString
#define decQuadCompare __decQuadCompare
#define decQuadCompareSignal __decQuadCompareSignal
#define decQuadCompareTotal __decQuadCompareTotal
#define decQuadCompareTotalMag __decQuadCompareTotalMag
#define decQuadCopy __decQuadCopy
#define decQuadCopyAbs __decQuadCopyAbs
#define decQuadCopyNegate __decQuadCopyNegate
#define decQuadCopySign __decQuadCopySign
#define decQuadDigits __decQuadDigits
#define decQuadDivide __decQuadDivide
#define decQuadDivideInteger __decQuadDivideInteger
#define decQuadFMA __decQuadFMA
#define decQuadFromBCD __decQuadFromBCD
#define decQuadFromInt32 __decQuadFromInt32
#define decQuadFromPacked __decQuadFromPacked
#define decQuadFromString __decQuadFromString
#define decQuadFromUInt32 __decQuadFromUInt32
#define decQuadGetCoefficient __decQuadGetCoefficient
#define decQuadGetExponent __decQuadGetExponent
#define decQuadInvert __decQuadInvert
#define decQuadIsCanonical __decQuadIsCanonical
#define decQuadIsFinite __decQuadIsFinite
#define decQuadIsInfinite __decQuadIsInfinite
#define decQuadIsInteger __decQuadIsInteger
#define decQuadIsNaN __decQuadIsNaN
#define decQuadIsNormal __decQuadIsNormal
#define decQuadIsSignaling __decQuadIsSignaling
#define decQuadIsSignalling __decQuadIsSignalling
#define decQuadIsSigned __decQuadIsSigned
#define decQuadIsSubnormal __decQuadIsSubnormal
#define decQuadIsZero __decQuadIsZero
#define decQuadLogB __decQuadLogB
#define decQuadMax __decQuadMax
#define decQuadMaxMag __decQuadMaxMag
#define decQuadMin __decQuadMin
#define decQuadMinMag __decQuadMinMag
#define decQuadMinus __decQuadMinus
#define decQuadMultiply __decQuadMultiply
#define decQuadNextMinus __decQuadNextMinus
#define decQuadNextPlus __decQuadNextPlus
#define decQuadNextToward __decQuadNextToward
#define decQuadOr __decQuadOr
#define decQuadPlus __decQuadPlus
#define decQuadQuantize __decQuadQuantize
#define decQuadRadix __decQuadRadix
#define decQuadReduce __decQuadReduce
#define decQuadRemainder __decQuadRemainder
#define decQuadRemainderNear __decQuadRemainderNear
#define decQuadRotate __decQuadRotate
#define decQuadSameQuantum __decQuadSameQuantum
#define decQuadScaleB __decQuadScaleB
#define decQuadSetCoefficient __decQuadSetCoefficient
#define decQuadSetExponent __decQuadSetExponent
#define decQuadShift __decQuadShift
#define decQuadShow __decQuadShow
#define decQuadSubtract __decQuadSubtract
#define decQuadToBCD __decQuadToBCD
#define decQuadToEngString __decQuadToEngString
#define decQuadToInt32 __decQuadToInt32
#define decQuadToInt32Exact __decQuadToInt32Exact
#define decQuadToIntegralExact __decQuadToIntegralExact
#define decQuadToIntegralValue __decQuadToIntegralValue
#define decQuadToPacked __decQuadToPacked
#define decQuadToString __decQuadToString
#define decQuadToUInt32 __decQuadToUInt32
#define decQuadToUInt32Exact __decQuadToUInt32Exact
#define decQuadVersion __decQuadVersion
#define decQuadXor __decQuadXor
#define decQuadZero __decQuadZero
#endif
#endif
/* decSingle module for the decNumber C Library.
Copyright (C) 2007 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
In addition to the permissions in the GNU General Public License,
the Free Software Foundation gives you unlimited permission to link
the compiled version of this file into combinations with other
programs, and to distribute those combinations without any
restriction coming from the use of this file. (The General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into a combine executable.)
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* ------------------------------------------------------------------ */
/* decSingle.c -- decSingle operations module */
/* ------------------------------------------------------------------ */
/* This module comprises decSingle operations (including conversions) */
/* ------------------------------------------------------------------ */
#include "decContext.h" /* public includes */
#include "decSingle.h" /* public includes */
/* Constant mappings for shared code */
#define DECPMAX DECSINGLE_Pmax
#define DECEMIN DECSINGLE_Emin
#define DECEMAX DECSINGLE_Emax
#define DECEMAXD DECSINGLE_EmaxD
#define DECBYTES DECSINGLE_Bytes
#define DECSTRING DECSINGLE_String
#define DECECONL DECSINGLE_EconL
#define DECBIAS DECSINGLE_Bias
#define DECLETS DECSINGLE_Declets
#define DECQTINY (-DECSINGLE_Bias)
/* parameters of next-wider format */
#define DECWBYTES DECDOUBLE_Bytes
#define DECWPMAX DECDOUBLE_Pmax
#define DECWECONL DECDOUBLE_EconL
#define DECWBIAS DECDOUBLE_Bias
/* Type and function mappings for shared code */
#define decFloat decSingle /* Type name */
#define decFloatWider decDouble /* Type name */
/* Utility (binary results, extractors, etc.) */
#define decFloatFromBCD decSingleFromBCD
#define decFloatFromPacked decSingleFromPacked
#define decFloatFromString decSingleFromString
#define decFloatFromWider decSingleFromWider
#define decFloatGetCoefficient decSingleGetCoefficient
#define decFloatGetExponent decSingleGetExponent
#define decFloatSetCoefficient decSingleSetCoefficient
#define decFloatSetExponent decSingleSetExponent
#define decFloatShow decSingleShow
#define decFloatToBCD decSingleToBCD
#define decFloatToEngString decSingleToEngString
#define decFloatToPacked decSingleToPacked
#define decFloatToString decSingleToString
#define decFloatToWider decSingleToWider
#define decFloatZero decSingleZero
/* Non-computational */
#define decFloatRadix decSingleRadix
#define decFloatVersion decSingleVersion
#include "decNumberLocal.h" /* local includes (need DECPMAX) */
#include "decCommon.c" /* non-basic decFloat routines */
/* [Do not include decBasic.c for decimal32] */
/* decSingle module header for the decNumber C Library.
Copyright (C) 2005 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.
In addition to the permissions in the GNU General Public License,
the Free Software Foundation gives you unlimited permission to link
the compiled version of this file into combinations with other
programs, and to distribute those combinations without any
restriction coming from the use of this file. (The General Public
License restrictions do apply in other respects; for example, they
cover modification of the file, and distribution when not linked
into a combine executable.)
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* ------------------------------------------------------------------ */
/* decSingle.h -- Decimal 32-bit format module header */
/* ------------------------------------------------------------------ */
/* Please see decFloats.h for an overview and documentation details. */
/* ------------------------------------------------------------------ */
#if !defined(DECSINGLE)
#define DECSINGLE
#define DECSINGLENAME "decSingle" /* Short name */
#define DECSINGLETITLE "Decimal 32-bit datum" /* Verbose name */
#define DECSINGLEAUTHOR "Mike Cowlishaw" /* Who to blame */
/* parameters for decSingles */
#define DECSINGLE_Bytes 4 /* length */
#define DECSINGLE_Pmax 7 /* maximum precision (digits) */
#define DECSINGLE_Emin -95 /* minimum adjusted exponent */
#define DECSINGLE_Emax 96 /* maximum adjusted exponent */
#define DECSINGLE_EmaxD 3 /* maximum exponent digits */
#define DECSINGLE_Bias 101 /* bias for the exponent */
#define DECSINGLE_String 16 /* maximum string length, +1 */
#define DECSINGLE_EconL 6 /* exponent continuation length */
#define DECSINGLE_Declets 2 /* count of declets */
/* highest biased exponent (Elimit-1) */
#define DECSINGLE_Ehigh (DECSINGLE_Emax + DECSINGLE_Bias - (DECSINGLE_Pmax-1))
/* Required includes */
#include "decContext.h"
#include "decQuad.h"
#include "decDouble.h"
/* The decSingle decimal 32-bit type, accessible by bytes */
typedef struct {
uint8_t bytes[DECSINGLE_Bytes]; /* fields: 1, 5, 6, 20 bits */
} decSingle;
/* ---------------------------------------------------------------- */
/* Routines -- implemented as decFloat routines in common files */
/* ---------------------------------------------------------------- */
#include "decSingleSymbols.h"
/* Utilities (binary argument(s) or result, extractors, etc.) */
extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t);
extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *);
extern decSingle * decSingleFromString(decSingle *, const char *, decContext *);
extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *);
extern int32_t decSingleGetCoefficient(const decSingle *, uint8_t *);
extern int32_t decSingleGetExponent(const decSingle *);
extern decSingle * decSingleSetCoefficient(decSingle *, const uint8_t *, int32_t);
extern decSingle * decSingleSetExponent(decSingle *, decContext *, int32_t);
extern void decSingleShow(const decSingle *, const char *);
extern int32_t decSingleToBCD(const decSingle *, int32_t *, uint8_t *);
extern char * decSingleToEngString(const decSingle *, char *);
extern int32_t decSingleToPacked(const decSingle *, int32_t *, uint8_t *);
extern char * decSingleToString(const decSingle *, char *);
extern decDouble * decSingleToWider(const decSingle *, decDouble *);
extern decSingle * decSingleZero(decSingle *);
/* (No Arithmetic routines for decSingle) */
/* Non-computational */
extern uint32_t decSingleRadix(const decSingle *);
extern const char * decSingleVersion(void);
/* decNumber conversions; these are implemented as macros so as not */
/* to force a dependency on decimal32 and decNumber in decSingle. */
#define decSingleToNumber(dq, dn) decimal32ToNumber((decimal32 *)(dq), dn)
#define decSingleFromNumber(dq, dn, set) (decSingle *)decimal32FromNumber((decimal32 *)(dq), dn, set)
#endif
#if !defined(DECSINGLESYMBOLS)
#define DECSINGLESYMBOLS
#ifdef IN_LIBGCC2
#define decSingleFromBCD __decSingleFromBCD
#define decSingleFromPacked __decSingleFromPacked
#define decSingleFromString __decSingleFromString
#define decSingleFromWider __decSingleFromWider
#define decSingleGetCoefficient __decSingleGetCoefficient
#define decSingleGetExponent __decSingleGetExponent
#define decSingleRadix __decSingleRadix
#define decSingleSetCoefficient __decSingleSetCoefficient
#define decSingleSetExponent __decSingleSetExponent
#define decSingleShow __decSingleShow
#define decSingleToBCD __decSingleToBCD
#define decSingleToEngString __decSingleToEngString
#define decSingleToPacked __decSingleToPacked
#define decSingleToString __decSingleToString
#define decSingleToWider __decSingleToWider
#define decSingleVersion __decSingleVersion
#define decSingleZero __decSingleZero
#endif
#endif
/* Decimal 128-bit format module header for the decNumber C Library
Copyright (C) 2005 Free Software Foundation, Inc.
/* Decimal 128-bit format module header for the decNumber C Library.
Copyright (C) 2005, 2007 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
......@@ -28,103 +28,74 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* ------------------------------------------------------------------ */
/* Decimal 128-bit format module header */
/* ------------------------------------------------------------------ */
#if !defined(DECIMAL128)
#define DECIMAL128
#define DEC128NAME "decimal128" /* Short name */
#define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */
#define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */
#if defined(DECIMAL32)
#error decimal128.h must precede decimal32.h for correct DECNUMDIGITS
#else
#if defined(DECIMAL64)
#error decimal128.h must precede decimal64.h for correct DECNUMDIGITS
#endif
#endif
#define DECIMAL128
#define DEC128NAME "decimal128" /* Short name */
#define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */
#define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */
/* parameters for decimal128s */
#define DECIMAL128_Bytes 16 /* length */
#define DECIMAL128_Pmax 34 /* maximum precision (digits) */
#define DECIMAL128_Emax 6144 /* maximum adjusted exponent */
#define DECIMAL128_Emin -6143 /* minimum adjusted exponent */
#define DECIMAL128_Bias 6176 /* bias for the exponent */
#define DECIMAL128_String 43 /* maximum string length, +1 */
/* highest biased exponent (Elimit-1) */
#define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)
#ifndef DECNUMDIGITS
#define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined */
#endif
#ifndef DECNUMBER
#include "decNumber.h" /* context and number library */
#endif
/* Decimal 128-bit type, accessible by bytes */
typedef struct
{
uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits */
} decimal128;
/* special values [top byte excluding sign bit; last two bits are
don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif
/* Macros for accessing decimal128 fields. These assume the argument
is a reference (pointer) to the decimal128 structure */
/* Get sign */
#define decimal128Sign(d) ((unsigned)(d)->bytes[0]>>7)
/* Get combination field */
#define decimal128Comb(d) (((d)->bytes[0] & 0x7c)>>2)
/* Get exponent continuation [does not remove bias] */
#define decimal128ExpCon(d) ((((d)->bytes[0] & 0x03)<<10) \
| ((unsigned)(d)->bytes[1]<<2) \
| ((unsigned)(d)->bytes[2]>>6))
/* Set sign [this assumes sign previously 0] */
#define decimal128SetSign(d, b) { \
(d)->bytes[0]|=((unsigned)(b)<<7);}
/* Clear sign */
#define decimal128ClearSign(d) {(d)->bytes[0]&=~0x80;}
/* Flip sign */
#define decimal128FlipSign(d) {(d)->bytes[0]^=0x80;}
/* Set exponent continuation [does not apply bias] */
/* This assumes range has been checked and exponent previously 0; */
/* type of exponent must be unsigned */
#define decimal128SetExpCon(d, e) { \
(d)->bytes[0]|=(uint8_t)((e)>>10); \
(d)->bytes[1] =(uint8_t)(((e)&0x3fc)>>2); \
(d)->bytes[2]|=(uint8_t)(((e)&0x03)<<6);}
/* ------------------------------------------------------------------ */
/* Routines */
/* ------------------------------------------------------------------ */
#ifdef IN_LIBGCC2
#ifndef decimal128FromString
#define decimal128FromString __decimal128FromString
#define decimal128ToString __decimal128ToString
#define decimal128ToEngString __decimal128ToEngString
#define decimal128FromNumber __decimal128FromNumber
#define decimal128ToNumber __decimal128ToNumber
#endif
#endif
/* String conversions */
decimal128 *decimal128FromString (decimal128 *, const char *, decContext *);
char *decimal128ToString (const decimal128 *, char *);
char *decimal128ToEngString (const decimal128 *, char *);
/* decNumber conversions */
decimal128 *decimal128FromNumber (decimal128 *, const decNumber *, decContext *);
decNumber *decimal128ToNumber (const decimal128 *, decNumber *);
#define DECIMAL128_Bytes 16 /* length */
#define DECIMAL128_Pmax 34 /* maximum precision (digits) */
#define DECIMAL128_Emax 6144 /* maximum adjusted exponent */
#define DECIMAL128_Emin -6143 /* minimum adjusted exponent */
#define DECIMAL128_Bias 6176 /* bias for the exponent */
#define DECIMAL128_String 43 /* maximum string length, +1 */
#define DECIMAL128_EconL 12 /* exp. continuation length */
/* highest biased exponent (Elimit-1) */
#define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1)
/* check enough digits, if pre-defined */
#if defined(DECNUMDIGITS)
#if (DECNUMDIGITS<DECIMAL128_Pmax)
#error decimal128.h needs pre-defined DECNUMDIGITS>=34 for safe use
#endif
#endif
#ifndef DECNUMDIGITS
#define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/
#endif
#ifndef DECNUMBER
#include "decNumber.h" /* context and number library */
#endif
/* Decimal 128-bit type, accessible by bytes */
typedef struct {
uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/
} decimal128;
/* special values [top byte excluding sign bit; last two bits are */
/* don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif
#include "decimal128Local.h"
/* ---------------------------------------------------------------- */
/* Routines */
/* ---------------------------------------------------------------- */
#include "decimal128Symbols.h"
/* String conversions */
decimal128 * decimal128FromString(decimal128 *, const char *, decContext *);
char * decimal128ToString(const decimal128 *, char *);
char * decimal128ToEngString(const decimal128 *, char *);
/* decNumber conversions */
decimal128 * decimal128FromNumber(decimal128 *, const decNumber *,
decContext *);
decNumber * decimal128ToNumber(const decimal128 *, decNumber *);
/* Format-dependent utilities */
uint32_t decimal128IsCanonical(const decimal128 *);
decimal128 * decimal128Canonical(decimal128 *, const decimal128 *);
#endif
/* Utility functions for decimal floating point support via decNumber.
Copyright (C) 2005 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
/* Local definitions for use with the decNumber C Library.
Copyright (C) 2007 Free Software Foundation, Inc.
This file is part of GCC.
......@@ -28,10 +27,21 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
#ifdef IN_LIBGCC2
#define decDensePackCoeff __decDensePackCoeff
#define decDenseUnpackCoeff __decDenseUnpackCoeff
#endif
#if !defined(DECIMAL128LOCAL)
/* The compiler needs sign manipulation functions for decimal128 which
are not part of the decNumber package. */
/* Set sign; this assumes the sign was previously zero. */
#define decimal128SetSign(d,b) \
{ (d)->bytes[FLOAT_WORDS_BIG_ENDIAN ? 0 : 15] |= ((unsigned) (b) << 7); }
extern void decDensePackCoeff (const decNumber *, uByte *, Int, Int);
extern void decDenseUnpackCoeff (const uByte *, Int, decNumber *, Int, Int);
/* Clear sign. */
#define decimal128ClearSign(d) \
{ (d)->bytes[FLOAT_WORDS_BIG_ENDIAN ? 0 : 15] &= ~0x80; }
/* Flip sign. */
#define decimal128FlipSign(d) \
{ (d)->bytes[FLOAT_WORDS_BIG_ENDIAN ? 0 : 15] ^= 0x80; }
#endif
#if !defined(DECIMAL128SYMBOLS)
#define DECIMAL128SYMBOLS
#ifdef IN_LIBGCC2
#define decDigitsFromDPD __decDigitsFromDPD
#define decDigitsToDPD __decDigitsToDPD
#define decimal128Canonical __decimal128Canonical
#define decimal128FromNumber __decimal128FromNumber
#define decimal128FromString __decimal128FromString
#define decimal128IsCanonical __decimal128IsCanonical
#define decimal128ToEngString __decimal128ToEngString
#define decimal128ToNumber __decimal128ToNumber
#define decimal128ToString __decimal128ToString
#endif
#endif
/* Decimal 32-bit format module header for the decNumber C Library
Copyright (C) 2005 Free Software Foundation, Inc.
/* Decimal 32-bit format module header for the decNumber C Library.
Copyright (C) 2005, 2007 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
......@@ -28,93 +28,72 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
/* ------------------------------------------------------------------ */
/* Decimal 32-bit format module header */
/* ------------------------------------------------------------------ */
#if !defined(DECIMAL32)
#define DECIMAL32
#define DEC32NAME "decimal32" /* Short name */
#define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */
#define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */
#define DECIMAL32
#define DEC32NAME "decimal32" /* Short name */
#define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */
#define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */
/* parameters for decimal32s */
#define DECIMAL32_Bytes 4 /* length */
#define DECIMAL32_Pmax 7 /* maximum precision (digits) */
#define DECIMAL32_Emax 96 /* maximum adjusted exponent */
#define DECIMAL32_Emin -95 /* minimum adjusted exponent */
#define DECIMAL32_Bias 101 /* bias for the exponent */
#define DECIMAL32_String 15 /* maximum string length, +1 */
/* highest biased exponent (Elimit-1) */
#define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)
#ifndef DECNUMDIGITS
#define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined */
#endif
#ifndef DECNUMBER
#include "decNumber.h" /* context and number library */
#endif
#define DECIMAL32_Bytes 4 /* length */
#define DECIMAL32_Pmax 7 /* maximum precision (digits) */
#define DECIMAL32_Emax 96 /* maximum adjusted exponent */
#define DECIMAL32_Emin -95 /* minimum adjusted exponent */
#define DECIMAL32_Bias 101 /* bias for the exponent */
#define DECIMAL32_String 15 /* maximum string length, +1 */
#define DECIMAL32_EconL 6 /* exp. continuation length */
/* highest biased exponent (Elimit-1) */
#define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1)
/* check enough digits, if pre-defined */
#if defined(DECNUMDIGITS)
#if (DECNUMDIGITS<DECIMAL32_Pmax)
#error decimal32.h needs pre-defined DECNUMDIGITS>=7 for safe use
#endif
#endif
#ifndef DECNUMDIGITS
#define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/
#endif
#ifndef DECNUMBER
#include "decNumber.h" /* context and number library */
#endif
/* Decimal 32-bit type, accessible by bytes */
typedef struct
{
uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits */
} decimal32;
/* special values [top byte excluding sign bit; last two bits are
don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif
/* Macros for accessing decimal32 fields. These assume the argument
is a reference (pointer) to the decimal32 structure */
/* Get sign */
#define decimal32Sign(d) ((unsigned)(d)->bytes[0]>>7)
/* Get combination field */
#define decimal32Comb(d) (((d)->bytes[0] & 0x7c)>>2)
/* Get exponent continuation [does not remove bias] */
#define decimal32ExpCon(d) ((((d)->bytes[0] & 0x03)<<4) \
| ((unsigned)(d)->bytes[1]>>4))
/* Set sign [this assumes sign previously 0] */
#define decimal32SetSign(d, b) { \
(d)->bytes[0]|=((unsigned)(b)<<7);}
/* Clear sign */
#define decimal32ClearSign(d) {(d)->bytes[0]&=~0x80;}
/* Flip sign */
#define decimal32FlipSign(d) {(d)->bytes[0]^=0x80;}
/* Set exponent continuation [does not apply bias] */
/* This assumes range has been checked and exponent previously 0; */
/* type of exponent must be unsigned */
#define decimal32SetExpCon(d, e) { \
(d)->bytes[0]|=(uint8_t)((e)>>4); \
(d)->bytes[1]|=(uint8_t)(((e)&0x0F)<<4);}
/* ------------------------------------------------------------------ */
/* Routines */
/* ------------------------------------------------------------------ */
#ifdef IN_LIBGCC2
#ifndef decimal32FromString
#define decimal32FromString __decimal32FromString
#define decimal32ToString __decimal32ToString
#define decimal32ToEngString __decimal32ToEngString
#define decimal32FromNumber __decimal32FromNumber
#define decimal32ToNumber __decimal32ToNumber
#endif
#endif
/* String conversions. */
decimal32 *decimal32FromString (decimal32 *, const char *, decContext *);
char *decimal32ToString (const decimal32 *, char *);
char *decimal32ToEngString (const decimal32 *, char *);
/* decNumber conversions. */
decimal32 *decimal32FromNumber (decimal32 *, const decNumber *, decContext *);
decNumber *decimal32ToNumber (const decimal32 *, decNumber *);
typedef struct {
uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits*/
} decimal32;
/* special values [top byte excluding sign bit; last two bits are */
/* don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif
/* ---------------------------------------------------------------- */
/* Routines */
/* ---------------------------------------------------------------- */
#include "decimal32Symbols.h"
/* String conversions */
decimal32 * decimal32FromString(decimal32 *, const char *, decContext *);
char * decimal32ToString(const decimal32 *, char *);
char * decimal32ToEngString(const decimal32 *, char *);
/* decNumber conversions */
decimal32 * decimal32FromNumber(decimal32 *, const decNumber *,
decContext *);
decNumber * decimal32ToNumber(const decimal32 *, decNumber *);
/* Format-dependent utilities */
uint32_t decimal32IsCanonical(const decimal32 *);
decimal32 * decimal32Canonical(decimal32 *, const decimal32 *);
#endif
#if !defined(DECIMAL32SYMBOLS)
#define DECIMAL32SYMBOLS
#ifdef IN_LIBGCC2
#define decDigitsFromDPD __decDigitsFromDPD
#define decDigitsToDPD __decDigitsToDPD
#define decimal32Canonical __decimal32Canonical
#define decimal32FromNumber __decimal32FromNumber
#define decimal32FromString __decimal32FromString
#define decimal32IsCanonical __decimal32IsCanonical
#define decimal32ToEngString __decimal32ToEngString
#define decimal32ToNumber __decimal32ToNumber
#define decimal32ToString __decimal32ToString
#endif
#endif
/* Decimal 64-bit format module header for the decNumber C Library
Copyright (C) 2005 Free Software Foundation, Inc.
/* Decimal 64-bit format module header for the decNumber C Library.
Copyright (C) 2005, 2007 Free Software Foundation, Inc.
Contributed by IBM Corporation. Author Mike Cowlishaw.
This file is part of GCC.
......@@ -28,97 +28,74 @@
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA. */
#if !defined(DECIMAL64)
#define DECIMAL64
#define DEC64NAME "decimal64" /* Short name */
#define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */
#define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */
#if defined(DECIMAL32)
#error decimal64.h must precede decimal32.h for correct DECNUMDIGITS
#endif
/* ------------------------------------------------------------------ */
/* Decimal 64-bit format module header */
/* ------------------------------------------------------------------ */
/* parameters for decimal64s */
#define DECIMAL64_Bytes 8 /* length */
#define DECIMAL64_Pmax 16 /* maximum precision (digits) */
#define DECIMAL64_Emax 384 /* maximum adjusted exponent */
#define DECIMAL64_Emin -383 /* minimum adjusted exponent */
#define DECIMAL64_Bias 398 /* bias for the exponent */
#define DECIMAL64_String 24 /* maximum string length, +1 */
/* highest biased exponent (Elimit-1) */
#define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)
#ifndef DECNUMDIGITS
#define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined */
#endif
#ifndef DECNUMBER
#include "decNumber.h" /* context and number library */
#endif
/* Decimal 64-bit type, accessible by bytes */
typedef struct
{
uint8_t bytes[DECIMAL64_Bytes]; /* decimal64: 1, 5, 8, 50 bits */
} decimal64;
/* special values [top byte excluding sign bit; last two bits are
don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif
/* Macros for accessing decimal64 fields. These assume the argument
is a reference (pointer) to the decimal64 structure */
/* Get sign */
#define decimal64Sign(d) ((unsigned)(d)->bytes[0]>>7)
/* Get combination field */
#define decimal64Comb(d) (((d)->bytes[0] & 0x7c)>>2)
/* Get exponent continuation [does not remove bias] */
#define decimal64ExpCon(d) ((((d)->bytes[0] & 0x03)<<6) \
| ((unsigned)(d)->bytes[1]>>2))
/* Set sign [this assumes sign previously 0] */
#define decimal64SetSign(d, b) { \
(d)->bytes[0]|=((unsigned)(b)<<7);}
/* Clear sign */
#define decimal64ClearSign(d) {(d)->bytes[0]&=~0x80;}
/* Flip sign */
#define decimal64FlipSign(d) {(d)->bytes[0]^=0x80;}
/* Set exponent continuation [does not apply bias] */
/* This assumes range has been checked and exponent previously 0; type */
/* of exponent must be unsigned */
#define decimal64SetExpCon(d, e) { \
(d)->bytes[0]|=(uint8_t)((e)>>6); \
(d)->bytes[1]|=(uint8_t)(((e)&0x3F)<<2);}
/* ------------------------------------------------------------------ */
/* Routines */
/* ------------------------------------------------------------------ */
#ifdef IN_LIBGCC2
#ifndef decimal64FromString
#define decimal64FromString __decimal64FromString
#define decimal64ToString __decimal64ToString
#define decimal64ToEngString __decimal64ToEngString
#define decimal64FromNumber __decimal64FromNumber
#define decimal64ToNumber __decimal64ToNumber
#endif
#endif
/* String conversions */
decimal64 *decimal64FromString (decimal64 *, const char *, decContext *);
char *decimal64ToString (const decimal64 *, char *);
char *decimal64ToEngString (const decimal64 *, char *);
/* decNumber conversions */
decimal64 *decimal64FromNumber (decimal64 *, const decNumber *, decContext *);
decNumber *decimal64ToNumber (const decimal64 *, decNumber *);
#if !defined(DECIMAL64)
#define DECIMAL64
#define DEC64NAME "decimal64" /* Short name */
#define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */
#define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */
/* parameters for decimal64s */
#define DECIMAL64_Bytes 8 /* length */
#define DECIMAL64_Pmax 16 /* maximum precision (digits) */
#define DECIMAL64_Emax 384 /* maximum adjusted exponent */
#define DECIMAL64_Emin -383 /* minimum adjusted exponent */
#define DECIMAL64_Bias 398 /* bias for the exponent */
#define DECIMAL64_String 24 /* maximum string length, +1 */
#define DECIMAL64_EconL 8 /* exp. continuation length */
/* highest biased exponent (Elimit-1) */
#define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1)
/* check enough digits, if pre-defined */
#if defined(DECNUMDIGITS)
#if (DECNUMDIGITS<DECIMAL64_Pmax)
#error decimal64.h needs pre-defined DECNUMDIGITS>=16 for safe use
#endif
#endif
#ifndef DECNUMDIGITS
#define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/
#endif
#ifndef DECNUMBER
#include "decNumber.h" /* context and number library */
#endif
/* Decimal 64-bit type, accessible by bytes */
typedef struct {
uint8_t bytes[DECIMAL64_Bytes]; /* decimal64: 1, 5, 8, 50 bits*/
} decimal64;
/* special values [top byte excluding sign bit; last two bits are */
/* don't-care for Infinity on input, last bit don't-care for NaN] */
#if !defined(DECIMAL_NaN)
#define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */
#define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */
#define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */
#endif
/* ---------------------------------------------------------------- */
/* Routines */
/* ---------------------------------------------------------------- */
#include "decimal64Symbols.h"
/* String conversions */
decimal64 * decimal64FromString(decimal64 *, const char *, decContext *);
char * decimal64ToString(const decimal64 *, char *);
char * decimal64ToEngString(const decimal64 *, char *);
/* decNumber conversions */
decimal64 * decimal64FromNumber(decimal64 *, const decNumber *,
decContext *);
decNumber * decimal64ToNumber(const decimal64 *, decNumber *);
/* Format-dependent utilities */
uint32_t decimal64IsCanonical(const decimal64 *);
decimal64 * decimal64Canonical(decimal64 *, const decimal64 *);
#endif
#if !defined(DECIMAL64SYMBOLS)
#define DECIMAL64SYMBOLS
#ifdef IN_LIBGCC2
#define decDigitsFromDPD __decDigitsFromDPD
#define decDigitsToDPD __decDigitsToDPD
#define decimal64Canonical __decimal64Canonical
#define decimal64FromNumber __decimal64FromNumber
#define decimal64FromString __decimal64FromString
#define decimal64IsCanonical __decimal64IsCanonical
#define decimal64ToEngString __decimal64ToEngString
#define decimal64ToNumber __decimal64ToNumber
#define decimal64ToString __decimal64ToString
#endif
#endif
2007-09-10 Janis Johnson <janis187@us.ibm.com>
* Makefile.in (dfp-filenames): Remove decUtility, add
decDouble, decPacked, decQuad, decSingle.
2007-08-27 Hans Kester <hans.kester@ellips.nl>
* config.host : Add x86_64-elf target.
......
......@@ -488,7 +488,7 @@ dfp-filenames += decimal_globals decimal_data binarydecimal \
bid128_to_int32 bid128_to_int64 \
bid128_to_uint32 bid128_to_uint64
else
dfp-filenames += decContext decNumber decExcept decRound decLibrary decUtility
dfp-filenames += decContext decNumber decExcept decRound decLibrary decDouble decPacked decQuad decSingle
endif
endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment