changeset 0392ef94d766 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=0392ef94d766
description:
        ext: Update fputils to rev 52b6190b4e

        This changeset updates the external library to git revision
        52b6190b4e. This update includes changes that fix compilation errors
        on old gcc versions and fixes to test a case that affect ICC.

diffstat:

 ext/fputils/configure.in           |   6 +++++-
 ext/fputils/fp80.c                 |  20 +++++++++-----------
 ext/fputils/fpbits.h               |   8 ++++----
 ext/fputils/include/fputils/fp80.h |  14 ++++++--------
 ext/fputils/tests/fp80_cvtd.c      |  13 +++++++++++--
 5 files changed, 35 insertions(+), 26 deletions(-)

diffs (165 lines):

diff -r 2935441b0870 -r 0392ef94d766 ext/fputils/configure.in
--- a/ext/fputils/configure.in  Mon Sep 30 12:20:53 2013 +0200
+++ b/ext/fputils/configure.in  Tue Oct 01 15:19:56 2013 +0200
@@ -12,10 +12,14 @@
 AC_REQUIRE_AUX_FILE([tap-driver.sh])
 
 AC_PROG_CC
-AM_PROG_CC_C_O
+AC_PROG_CC_C99
 AC_PROG_LIBTOOL
 AC_PROG_AWK
 
+if test "x$ac_cv_prog_cc_c99" = "xno"; then
+  AC_MSG_ERROR([Could not enable C99 support in compiler.])
+fi
+
 AM_CFLAGS="-Wall -Werror"
 AM_CPPFLAGS="-I\$(abs_top_srcdir)/include"
 
diff -r 2935441b0870 -r 0392ef94d766 ext/fputils/fp80.c
--- a/ext/fputils/fp80.c        Mon Sep 30 12:20:53 2013 +0200
+++ b/ext/fputils/fp80.c        Tue Oct 01 15:19:56 2013 +0200
@@ -36,10 +36,8 @@
 #include <stdio.h>
 
 typedef union {
-    union {
-        uint64_t bits;
-        double value;
-    };
+    uint64_t bits;
+    double value;
 } fp64_t;
 
 
@@ -74,7 +72,7 @@
 int
 fp80_sgn(fp80_t fp80)
 {
-    return (fp80.u.repr.se & FP80_SIGN_BIT) ? -1 : 1;
+    return (fp80.repr.se & FP80_SIGN_BIT) ? -1 : 1;
 }
 
 int
@@ -105,9 +103,9 @@
 int
 fp80_isqnani(fp80_t fp80)
 {
-    const uint64_t frac_low = fp80.u.repr.fi & (FP80_FRAC_MASK >> 1);
+    const uint64_t frac_low = fp80.repr.fi & (FP80_FRAC_MASK >> 1);
 
-    return fp80_isqnan(fp80) && (fp80.u.repr.se & FP80_SIGN_BIT) && !frac_low;
+    return fp80_isqnan(fp80) && (fp80.repr.se & FP80_SIGN_BIT) && !frac_low;
 }
 
 int
@@ -133,7 +131,7 @@
 int
 fp80_iszero(fp80_t fp80)
 {
-    return fp80.u.repr.fi == 0 && FP80_EXP(fp80) == 0 ? fp80_sgn(fp80) : 0;
+    return fp80.repr.fi == 0 && FP80_EXP(fp80) == 0 ? fp80_sgn(fp80) : 0;
 }
 
 int
@@ -169,10 +167,10 @@
 double
 fp80_cvtd(fp80_t fp80)
 {
-    const int sign = fp80.u.repr.se & FP80_SIGN_BIT;
+    const int sign = fp80.repr.se & FP80_SIGN_BIT;
 
     if (!fp80_isspecial(fp80)) {
-        const uint64_t frac = fp80.u.repr.fi;
+        const uint64_t frac = fp80.repr.fi;
         const int unb_exp = FP80_EXP(fp80) - FP80_EXP_BIAS;
         const int fp64_exp = unb_exp + FP64_EXP_BIAS;
         const uint64_t fp64_frac = frac >> (FP80_FRAC_BITS - FP64_FRAC_BITS);
@@ -242,6 +240,6 @@
 fp80_debug_dump(FILE *fout, fp80_t fp80)
 {
     fprintf(fout, "sgn: %i, int: %i, frac: 0x%llx, exp: 0x%x (%i)\n",
-            fp80_sgn(fp80), !!(fp80.u.repr.fi & FP80_INT_BIT), FP80_FRAC(fp80),
+            fp80_sgn(fp80), !!(fp80.repr.fi & FP80_INT_BIT), FP80_FRAC(fp80),
             FP80_EXP(fp80), FP80_EXP(fp80) - FP80_EXP_BIAS);
 }
diff -r 2935441b0870 -r 0392ef94d766 ext/fputils/fpbits.h
--- a/ext/fputils/fpbits.h      Mon Sep 30 12:20:53 2013 +0200
+++ b/ext/fputils/fpbits.h      Tue Oct 01 15:19:56 2013 +0200
@@ -76,15 +76,15 @@
 
 #define BUILD_FP80(sign, frac, exp)                             \
     {                                                           \
-        .u.repr.se = BUILD_FP80_SE(sign, exp),                  \
-        .u.repr.fi = BUILD_FP80_FI(frac, exp)                   \
+        .repr.se = BUILD_FP80_SE(sign, exp),                    \
+        .repr.fi = BUILD_FP80_FI(frac, exp)                     \
     }
 
 #define FP80_FRAC(fp80)                                         \
-    (fp80.u.repr.fi & FP80_FRAC_MASK)
+    (fp80.repr.fi & FP80_FRAC_MASK)
 
 #define FP80_EXP(fp80)                                          \
-    (fp80.u.repr.se & FP80_EXP_MASK)
+    (fp80.repr.se & FP80_EXP_MASK)
 
 #define FP64_FRAC(fp64)                                         \
     (fp64.bits & FP64_FRAC_MASK)
diff -r 2935441b0870 -r 0392ef94d766 ext/fputils/include/fputils/fp80.h
--- a/ext/fputils/include/fputils/fp80.h        Mon Sep 30 12:20:53 2013 +0200
+++ b/ext/fputils/include/fputils/fp80.h        Tue Oct 01 15:19:56 2013 +0200
@@ -46,14 +46,12 @@
  */
 
 /** Internal representation of an 80-bit float. */
-typedef struct  {
-    union {
-        char bits[10];
-        struct {
-            uint64_t fi;
-            uint16_t se;
-        } repr;
-    } u;
+typedef union  {
+    char bits[10];
+    struct {
+        uint64_t fi;
+        uint16_t se;
+    } repr;
 } fp80_t;
 
 /** Constant representing +inf */
diff -r 2935441b0870 -r 0392ef94d766 ext/fputils/tests/fp80_cvtd.c
--- a/ext/fputils/tests/fp80_cvtd.c     Mon Sep 30 12:20:53 2013 +0200
+++ b/ext/fputils/tests/fp80_cvtd.c     Tue Oct 01 15:19:56 2013 +0200
@@ -35,6 +35,15 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+/* We provide our own version of isinf_sgn since the C99 standard
+ * doesn't guarantee that isinf() returns the sign of the infinity
+ * (most implementations do). */
+static inline int
+isinf_sgn(double x)
+{
+    return isinf(x) ? (signbit(x) ? -1 : 1) : 0;
+}
+
 static void
 test_fp80_cvtd_class(const char *name, fp80_t fin, int class)
 {
@@ -48,10 +57,10 @@
 }
 
 static void
-test_fp80_cvtd_inf(const char *name, fp80_t fin, int inf_class)
+test_fp80_cvtd_inf(const char *name, fp80_t fin, int expected_inf_class)
 {
     double d = fp80_cvtd(fin);
-    if (isinf(d) != inf_class) {
+    if (isinf_sgn(d) != expected_inf_class) {
         test_diag("wrong infinity type");
         test_fail(name);
     } else {
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to