aboutsummaryrefslogtreecommitdiff
path: root/libdecnumber
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2008-10-27 18:25:21 +0000
committerDJ Delorie <dj@redhat.com>2008-10-27 18:25:21 +0000
commitaed1add31bf14e0cf760f01ac02437988b5762c3 (patch)
treeaed74a60e958fae99dbc27b9032af421751ce3ff /libdecnumber
parente8ecdb5c3b219e270f6f3589129d49598e118fc5 (diff)
downloadgdb-aed1add31bf14e0cf760f01ac02437988b5762c3.zip
gdb-aed1add31bf14e0cf760f01ac02437988b5762c3.tar.gz
gdb-aed1add31bf14e0cf760f01ac02437988b5762c3.tar.bz2
merge from gcc
Diffstat (limited to 'libdecnumber')
-rw-r--r--libdecnumber/ChangeLog12
-rw-r--r--libdecnumber/decBasic.c12
-rw-r--r--libdecnumber/decDouble.h6
-rw-r--r--libdecnumber/decNumberLocal.h12
-rw-r--r--libdecnumber/decQuad.h6
-rw-r--r--libdecnumber/decSingle.h6
6 files changed, 38 insertions, 16 deletions
diff --git a/libdecnumber/ChangeLog b/libdecnumber/ChangeLog
index a89179b..eec0866 100644
--- a/libdecnumber/ChangeLog
+++ b/libdecnumber/ChangeLog
@@ -1,3 +1,15 @@
+2008-10-27 Janis Johnson <janis187@us.ibm.com>
+
+ PR other/37897
+ * decDouble.h (decDouble): Replace struct with union accessible
+ by more types.
+ * decSingle.h (decSingle): Ditto.
+ * decQuad.h (decQuad): Ditto.
+ * decNumberLocal.h (DFWORD, DFBYTE, DFWWORD): access decFloat via
+ new members.
+ * decBasic.c (decFloatCompareTotal): Avoid type-pun violation.
+ (decNumberCompare): Ditto.
+
2008-06-17 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* Makefile.in ($(srcdir)/aclocal.m4): Update dependencies.
diff --git a/libdecnumber/decBasic.c b/libdecnumber/decBasic.c
index 9ce277d..fddba97 100644
--- a/libdecnumber/decBasic.c
+++ b/libdecnumber/decBasic.c
@@ -1660,8 +1660,10 @@ decFloat * decFloatCompareTotal(decFloat *result,
/* decode the coefficients */
/* (shift both right two if Quad to make a multiple of four) */
#if QUAD
- USHORTAT(bufl)=0;
- USHORTAT(bufr)=0;
+ ub = bufl; /* avoid type-pun violation */
+ USHORTAT(ub)=0;
+ uc = bufr; /* avoid type-pun violation */
+ USHORTAT(uc)=0;
#endif
GETCOEFF(dfl, bufl+QUAD*2); /* decode from decFloat */
GETCOEFF(dfr, bufr+QUAD*2); /* .. */
@@ -3542,8 +3544,10 @@ static Int decNumCompare(const decFloat *dfl, const decFloat *dfr, Flag tot) {
/* decode the coefficients */
/* (shift both right two if Quad to make a multiple of four) */
#if QUAD
- UINTAT(bufl)=0;
- UINTAT(bufr)=0;
+ ub=bufl; /* avoid type-pun violation */
+ UINTAT(ub)=0;
+ uc=bufr; /* avoid type-pun violation */
+ UINTAT(uc)=0;
#endif
GETCOEFF(dfl, bufl+QUAD*2); /* decode from decFloat */
GETCOEFF(dfr, bufr+QUAD*2); /* .. */
diff --git a/libdecnumber/decDouble.h b/libdecnumber/decDouble.h
index 32eba39..53fcf40 100644
--- a/libdecnumber/decDouble.h
+++ b/libdecnumber/decDouble.h
@@ -58,9 +58,11 @@
#include "decContext.h"
#include "decQuad.h"
- /* The decDouble decimal 64-bit type, accessible by bytes */
- typedef struct {
+ /* The decDouble decimal 64-bit type, accessible by various types */
+ typedef union {
uint8_t bytes[DECDOUBLE_Bytes]; /* fields: 1, 5, 8, 50 bits */
+ uint16_t shorts[DECDOUBLE_Bytes/2];
+ uint32_t words[DECDOUBLE_Bytes/4];
} decDouble;
/* ---------------------------------------------------------------- */
diff --git a/libdecnumber/decNumberLocal.h b/libdecnumber/decNumberLocal.h
index 809eaa4..f1568f7 100644
--- a/libdecnumber/decNumberLocal.h
+++ b/libdecnumber/decNumberLocal.h
@@ -308,13 +308,13 @@
#define DECWORDS (DECBYTES/4)
#define DECWWORDS (DECWBYTES/4)
#if DECLITEND
- #define DFWORD(df, off) UINTAT((df)->bytes+(DECWORDS-1-(off))*4)
- #define DFBYTE(df, off) UBYTEAT((df)->bytes+(DECBYTES-1-(off)))
- #define DFWWORD(dfw, off) UINTAT((dfw)->bytes+(DECWWORDS-1-(off))*4)
+ #define DFWORD(df, off) ((df)->words[DECWORDS-1-(off)])
+ #define DFBYTE(df, off) ((df)->bytes[DECBYTES-1-(off)])
+ #define DFWWORD(dfw, off) ((dfw)->words[DECWWORDS-1-(off)])
#else
- #define DFWORD(df, off) UINTAT((df)->bytes+(off)*4)
- #define DFBYTE(df, off) UBYTEAT((df)->bytes+(off))
- #define DFWWORD(dfw, off) UINTAT((dfw)->bytes+(off)*4)
+ #define DFWORD(df, off) ((df)->words[off])
+ #define DFBYTE(df, off) ((df)->bytes[off])
+ #define DFWWORD(dfw, off) ((dfw)->words[off])
#endif
/* Tests for sign or specials, directly on DECFLOATs */
diff --git a/libdecnumber/decQuad.h b/libdecnumber/decQuad.h
index 39f75d3..af9bc24 100644
--- a/libdecnumber/decQuad.h
+++ b/libdecnumber/decQuad.h
@@ -59,9 +59,11 @@
/* Required include */
#include "decContext.h"
- /* The decQuad decimal 128-bit type, accessible by bytes */
- typedef struct {
+ /* The decQuad decimal 128-bit type, accessible by various types */
+ typedef union {
uint8_t bytes[DECQUAD_Bytes]; /* fields: 1, 5, 12, 110 bits */
+ uint16_t shorts[DECQUAD_Bytes/2];
+ uint32_t words[DECQUAD_Bytes/4];
} decQuad;
/* ---------------------------------------------------------------- */
diff --git a/libdecnumber/decSingle.h b/libdecnumber/decSingle.h
index 8dd1bd3..bae3984 100644
--- a/libdecnumber/decSingle.h
+++ b/libdecnumber/decSingle.h
@@ -59,9 +59,11 @@
#include "decQuad.h"
#include "decDouble.h"
- /* The decSingle decimal 32-bit type, accessible by bytes */
- typedef struct {
+ /* The decSingle decimal 32-bit type, accessible by various types */
+ typedef union {
uint8_t bytes[DECSINGLE_Bytes]; /* fields: 1, 5, 6, 20 bits */
+ uint16_t shorts[DECSINGLE_Bytes/2];
+ uint32_t words[DECSINGLE_Bytes/4];
} decSingle;
/* ---------------------------------------------------------------- */