Bruce Korb <bk...@gnu.org> writes: > On 01/29/15 05:38, Rainer Orth wrote: >> So I saw. If all else fails, we can still commit the (ugly/hard to >> read) initial version, otherwise libgo won't build on Solaris before >> some (quite recent) Solaris 11.2 patch, breaking bootstrap. > > Having it work at all seems like a nice feature. > I think that: > > test-text = <<_EOF_ > [[....]] > _EOF_; > > is likely still better than the quoted string, though. > Without the little hyphen ("<<-"), the leading tabs are > not stripped. At this point, whatever is easiest for you. :)
That worked fine indeed and is considerably more readable than my previous version. It produced the identical fixincl.x, passed fixincludes make check and Solaris 10 and 11 bootstraps. Ok for mainline now, I guess? Thanks Rainer 2014-06-25 Rainer Orth <r...@cebitec.uni-bielefeld.de> 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.
# HG changeset patch # Parent 0cdc6d5a3025bfda451a6a0e6c304b36eaf39d8f Fix <iso/math_c99.h> signbit on Solaris diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -3549,6 +3549,58 @@ fix = { }; /* + * 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 * contains one. Wrap the macro definition in an extra layer. diff --git a/fixincludes/tests/base/iso/math_c99.h b/fixincludes/tests/base/iso/math_c99.h --- a/fixincludes/tests/base/iso/math_c99.h +++ b/fixincludes/tests/base/iso/math_c99.h @@ -75,3 +75,14 @@ #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 */ diff --git a/gcc/testsuite/gcc.dg/signbit-sa.c b/gcc/testsuite/gcc.dg/signbit-sa.c new file mode 100644 --- /dev/null +++ b/gcc/testsuite/gcc.dg/signbit-sa.c @@ -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);; +}
-- ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University