]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix <iso/math_c99.h> signbit on Solaris
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Tue, 10 Feb 2015 10:09:49 +0000 (10:09 +0000)
committerRainer Orth <ro@gcc.gnu.org>
Tue, 10 Feb 2015 10:09:49 +0000 (10:09 +0000)
fixincludes:
* inclhack.def (solaris_math_11): New fix.
* fixincl.x: Regenerate.
* tests/base/iso/math_c99.h [SOLARIS_MATH_11_CHECK]: New test.

gcc/testsuite:
* gcc.dg/signbit-sa.c: New test.

From-SVN: r220577

fixincludes/ChangeLog
fixincludes/fixincl.x
fixincludes/inclhack.def
fixincludes/tests/base/iso/math_c99.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/signbit-sa.c [new file with mode: 0644]

index c6ae152f7bffe5bfb8ae4ae419cabd042840f6a7..f5483cf72d15b9a8a35d898611321b83c5c40b4f 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * inclhack.def (solaris_math_11): New fix.
+       * fixincl.x: Regenerate.
+       * tests/base/iso/math_c99.h [SOLARIS_MATH_11_CHECK]: New test.
+
 2015-02-06  David Edelsohn  <dje.gcc@gmail.com>
 
        PR bootstrap/53348
index 42009e990727e6f8b5ffe523a3725c5dacb04cad..77a9c321a3d528b34d0deb09b0b2133d7b4b8977 100644 (file)
@@ -1,12 +1,12 @@
 /*  -*- buffer-read-only: t -*- vi: set ro:
- *
+ * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
- *
- * It has been AutoGen-ed  December 20, 2014 at 03:22:33 PM by AutoGen 5.18.5pre6
+ * 
+ * It has been AutoGen-ed  Friday February  6, 2015 at 04:31:58 PM CET
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Dec 20 15:22:33 PST 2014
+/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Feb  6 16:31:58 CET 2015
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 223 fixup descriptions.
+ * This file contains 224 fixup descriptions.
  *
  * See README for more information.
  *
@@ -6856,6 +6856,60 @@ static const char* apzSolaris_Math_9Patch[] = {
     "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) __builtin_[a-z]+\\(y\\)\\)",
     (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Solaris_Math_11 fix
+ */
+tSCC zSolaris_Math_11Name[] =
+     "solaris_math_11";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zSolaris_Math_11List[] =
+  "iso/math_c99.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+#define apzSolaris_Math_11Machs (const char**)NULL
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zSolaris_Math_11Select0[] =
+       "@\\(#\\)math_c99\\.h[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
+
+#define    SOLARIS_MATH_11_TEST_CT  1
+static tTestDesc aSolaris_Math_11Tests[] = {
+  { TT_EGREP,    zSolaris_Math_11Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Solaris_Math_11
+ */
+static const char* apzSolaris_Math_11Patch[] = {
+    "format",
+    "#undef\tsignbit\n\
+#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n\
+\t\t\t   ? __builtin_signbitf(x) \\\n\
+\t\t\t   : sizeof(x) == sizeof(long double) \\\n\
+\t\t\t     ? __builtin_signbitl(x) \\\n\
+\t\t\t     : __builtin_signbit(x))",
+    "^#undef[ \t]+signbit\n\
+#if defined\\(__sparc\\)\n\
+#define[ \t]+signbit\\(x\\)[ \t]+__extension__\\( \\\\\n\
+[ \t]+\\{[ \t]*__typeof\\(x\\)[ \t]*__x_s[ \t]*=[ \t]*\\(x\\);[ \t]*\\\\\n\
+[ \t]+\\(int\\)[ \t]*\\(\\*\\(unsigned[ \t]*\\*\\)[ \t]*\\&__x_s[ \t]*>>[ \t]*31\\);[ \t]*\\}\\)\n\
+#elif defined\\(__i386\\) \\|\\| defined\\(__amd64\\)\n\
+#define[ \t]+signbit\\(x\\)[ \t]+__extension__\\( \\\\\n\
+[ \t]+\\{ __typeof\\(x\\) __x_s = \\(x\\); \\\\\n\
+[ \t]+\\(sizeof \\(__x_s\\) == sizeof \\(float\\) \\? \\\\\n\
+[ \t]+\\(int\\) \\(\\*\\(unsigned \\*\\) \\&__x_s >> 31\\) : \\\\\n\
+[ \t]+sizeof \\(__x_s\\) == sizeof \\(double\\) \\? \\\\\n\
+[ \t]+\\(int\\) \\(\\(\\(unsigned \\*\\) \\&__x_s\\)\\[1\\] >> 31\\) : \\\\\n\
+[ \t]+\\(int\\) \\(\\(\\(unsigned short \\*\\) \\&__x_s\\)\\[4\\] >> 15\\)\\); \\}\\)\n\
+#endif",
+    (char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Solaris_Once_Init_1 fix
@@ -9152,9 +9206,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          260
+#define REGEX_COUNT          261
 #define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT            223
+#define FIX_COUNT            224
 
 /*
  *  Enumerate the fixes
@@ -9325,6 +9379,7 @@ typedef enum {
     SOLARIS_MATH_4_FIXIDX,
     SOLARIS_MATH_8_FIXIDX,
     SOLARIS_MATH_9_FIXIDX,
+    SOLARIS_MATH_11_FIXIDX,
     SOLARIS_ONCE_INIT_1_FIXIDX,
     SOLARIS_POSIX_SPAWN_RESTRICT_FIXIDX,
     SOLARIS_POW_INT_OVERLOAD_FIXIDX,
@@ -10211,6 +10266,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
      SOLARIS_MATH_9_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aSolaris_Math_9Tests,   apzSolaris_Math_9Patch, 0 },
 
+  {  zSolaris_Math_11Name,    zSolaris_Math_11List,
+     apzSolaris_Math_11Machs,
+     SOLARIS_MATH_11_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aSolaris_Math_11Tests,   apzSolaris_Math_11Patch, 0 },
+
   {  zSolaris_Once_Init_1Name,    zSolaris_Once_Init_1List,
      apzSolaris_Once_Init_1Machs,
      SOLARIS_ONCE_INIT_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
index fa9287e50fd7d85d80e4ae788416f9e4b5dfbd01..ce9a2ca6b4c5b9cdc1562771571c2b6456d6bf76 100644 (file)
@@ -3548,6 +3548,58 @@ fix = {
     "#define   isunordered(x, y)       ((x) __builtin_isunordered(y))";
 };
 
+/*
+ * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
+ * warnings.
+ */
+fix = {
+    hackname = solaris_math_11;
+    select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
+    files = iso/math_c99.h;
+    c_fix = format;
+    c_fix_arg = << _EOArg_
+#undef signbit
+#define        signbit(x)      (sizeof(x) == sizeof(float) \
+                          ? __builtin_signbitf(x) \
+                          : sizeof(x) == sizeof(long double) \
+                            ? __builtin_signbitl(x) \
+                            : __builtin_signbit(x))
+_EOArg_;
+    c_fix_arg = << _EOArg_
+^#undef[       ]+signbit
+#if defined\(__sparc\)
+#define[       ]+signbit\(x\)[         ]+__extension__\( \\
+[      ]+\{[   ]*__typeof\(x\)[        ]*__x_s[        ]*=[    ]*\(x\);[       ]*\\
+[      ]+\(int\)[      ]*\(\*\(unsigned[       ]*\*\)[         ]*\&__x_s[      ]*>>[   ]*31\);[        ]*\}\)
+#elif defined\(__i386\) \|\| defined\(__amd64\)
+#define[       ]+signbit\(x\)[         ]+__extension__\( \\
+[      ]+\{ __typeof\(x\) __x_s = \(x\); \\
+[      ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
+[      ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
+[      ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
+[      ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
+[      ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
+#endif
+_EOArg_;
+    test_text = << _EOText_
+/* @(#)math_c99.h      1.14    13/03/27 */
+#undef signbit
+#if defined(__sparc)
+#define        signbit(x)      __extension__( \\
+                               { __typeof(x) __x_s = (x); \\
+                               (int) (*(unsigned *) &__x_s >> 31); })
+#elif defined(__i386) || defined(__amd64)
+#define        signbit(x)      __extension__( \\
+                       { __typeof(x) __x_s = (x); \\
+                       (sizeof (__x_s) == sizeof (float) ? \\
+                       (int) (*(unsigned *) &__x_s >> 31) : \\
+                       sizeof (__x_s) == sizeof (double) ? \\
+                       (int) (((unsigned *) &__x_s)[1] >> 31) : \\
+                       (int) (((unsigned short *) &__x_s)[4] >> 15)); })
+#endif
+_EOText_;
+};
+
 /*
  * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
  * structure.  As such, it need two levels of brackets, but only
index 3758cb9b5bcb772b2b00206b9e32170f57192ed0..6c642e5852944ba23b60084183a4732f126c321c 100644 (file)
 #undef isunordered
 #define        isunordered(x, y)       __builtin_isunordered(x, y)
 #endif  /* SOLARIS_MATH_9_CHECK */
+
+
+#if defined( SOLARIS_MATH_11_CHECK )
+/* @(#)math_c99.h      1.14    13/03/27 */
+#undef signbit
+#define        signbit(x)      (sizeof(x) == sizeof(float) \
+                          ? __builtin_signbitf(x) \
+                          : sizeof(x) == sizeof(long double) \
+                            ? __builtin_signbitl(x) \
+                            : __builtin_signbit(x))
+#endif  /* SOLARIS_MATH_11_CHECK */
index 67e1ac47de8a76d36491341023fe738365d7f9a3..9bb681c6193b30832d86e5d0ef1f67fb43b6ec90 100644 (file)
@@ -1,3 +1,7 @@
+2015-02-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * gcc.dg/signbit-sa.c: New test.
+
 2015-02-10  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR libgfortran/57822
diff --git a/gcc/testsuite/gcc.dg/signbit-sa.c b/gcc/testsuite/gcc.dg/signbit-sa.c
new file mode 100644 (file)
index 0000000..4cbefdd
--- /dev/null
@@ -0,0 +1,11 @@
+/* Some versions of Solaris <math.h> give strict-aliasing warnings for
+   signbit.  */
+/* { dg-options "-std=c99 -O2 -Wstrict-aliasing" } */
+
+#include <math.h>
+
+int
+main (void)
+{
+  return signbit (1.0f) | signbit (1.0) | signbit (1.0l);;
+}