OSDN Git Service

* gcc.c-torture/execute/ieee/copysign1.c: Special case sizeof
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 31 Jan 2005 09:10:01 +0000 (09:10 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 31 Jan 2005 09:10:01 +0000 (09:10 +0000)
        long double for intel double extended format.
        * gcc.c-torture/execute/ieee/copysign2.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94472 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/ieee/copysign1.c
gcc/testsuite/gcc.c-torture/execute/ieee/copysign2.c

index 30a3bca..648c97b 100644 (file)
@@ -1,3 +1,9 @@
+2005-01-31  Richard Henderson  <rth@redhat.com>
+
+       * gcc.c-torture/execute/ieee/copysign1.c: Special case sizeof
+       long double for intel double extended format.
+       * gcc.c-torture/execute/ieee/copysign2.c: Likewise.
+
 2005-01-30  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/19555
index 3197d2e..6f6a215 100644 (file)
@@ -1,5 +1,22 @@
 #include <string.h>
 #include <stdlib.h>
+#include <float.h>
+
+#define fpsizeoff      sizeof(float)
+#define fpsizeof       sizeof(double)
+#define fpsizeofl      sizeof(long double)
+
+/* Work around the fact that with the Intel double-extended precision,
+   we've got a 10 byte type stuffed into some amount of padding.  And
+   the fact that -ffloat-store is going to stuff this value temporarily
+   into some bit of stack frame that we've no control over and can't zero.  */
+#if LDBL_MANT_DIG == 64
+# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)
+#  undef fpsizeofl
+#  define fpsizeofl    10
+# endif
+#endif
+
 
 #define TEST(TYPE, EXT)                                                \
 TYPE c##EXT (TYPE x, TYPE y)                                   \
@@ -25,12 +42,10 @@ void test##EXT (void)                                               \
 {                                                              \
   int i, n = sizeof (T##EXT) / sizeof (T##EXT[0]);             \
   TYPE r;                                                      \
-  /* Make sure to avoid comparing unused bits in the type.  */ \
-  memset (&r, 0, sizeof r);                                    \
   for (i = 0; i < n; ++i)                                      \
     {                                                          \
       r = c##EXT (T##EXT[i].x, T##EXT[i].y);                   \
-      if (memcmp (&r, &T##EXT[i].z, sizeof r) != 0)            \
+      if (memcmp (&r, &T##EXT[i].z, fpsizeof##EXT) != 0)       \
        abort ();                                               \
     }                                                          \
 }
index d715992..a39d115 100644 (file)
@@ -1,5 +1,23 @@
 #include <string.h>
 #include <stdlib.h>
+#include <float.h>
+
+#define fpsizeoff      sizeof(float)
+#define fpsizeof       sizeof(double)
+#define fpsizeofl      sizeof(long double)
+
+/* Work around the fact that with the Intel double-extended precision,
+   we've got a 10 byte type stuffed into some amount of padding.  And
+   the fact that -ffloat-store is going to stuff this value temporarily
+   into some bit of stack frame that we've no control over and can't zero.  */
+#if LDBL_MANT_DIG == 64
+# if defined(__i386__) || defined(__x86_64__) || defined (__ia64__)
+#  undef fpsizeofl
+#  define fpsizeofl    10
+# endif
+#endif
+
+
 
 #define TEST(TYPE, EXT)                                                \
 static TYPE Y##EXT[] = {                                       \
@@ -13,8 +31,7 @@ static const TYPE Z##EXT[] = {                                        \
 void test##EXT (void)                                          \
 {                                                              \
   TYPE r[8];                                                   \
-  /* Make sure to avoid comparing unused bits in the type.  */ \
-  memset (r, 0, sizeof r);                                     \
+  int i;                                                       \
   r[0] = __builtin_copysign##EXT (1.0, Y##EXT[0]);             \
   r[1] = __builtin_copysign##EXT (1.0, Y##EXT[1]);             \
   r[2] = __builtin_copysign##EXT (-1.0, Y##EXT[2]);            \
@@ -23,8 +40,9 @@ void test##EXT (void)                                         \
   r[5] = __builtin_copysign##EXT (-0.0, Y##EXT[5]);            \
   r[6] = __builtin_copysign##EXT (__builtin_inf##EXT (), Y##EXT[6]); \
   r[7] = __builtin_copysign##EXT (-__builtin_nan##EXT (""), Y##EXT[7]); \
-  if (memcmp (r, Z##EXT, sizeof r) != 0)                       \
-    abort ();                                                  \
+  for (i = 0; i < 8; ++i)                                      \
+    if (memcmp (r+i, Z##EXT+i, fpsizeof##EXT) != 0)            \
+      abort ();                                                        \
 }
 
 TEST(float, f)