From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
To: Bruce Korb <bkorb@gnu.org>
Cc: Bruce Korb <bruce.korb@gmail.com>,
GCC Patches <gcc-patches@gcc.gnu.org>,
"Joseph S. Myers" <joseph@codesourcery.com>
Subject: Re: [fixincludes] Fix <iso/math_c99.h> signbit on Solaris
Date: Mon, 09 Feb 2015 11:31:00 -0000 [thread overview]
Message-ID: <ydd7fvrz5hs.fsf@lokon.CeBiTec.Uni-Bielefeld.DE> (raw)
In-Reply-To: <54CBC82F.5000604@gnu.org> (Bruce Korb's message of "Fri, 30 Jan 2015 10:06:39 -0800")
[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]
Bruce Korb <bkorb@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 <ro@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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-signbit.patch --]
[-- Type: text/x-patch, Size: 3345 bytes --]
# 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);;
+}
[-- Attachment #3: Type: text/plain, Size: 143 bytes --]
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
next prev parent reply other threads:[~2015-02-09 11:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-01 17:48 Bruce Korb
2015-01-28 15:17 ` Rainer Orth
2015-01-28 18:51 ` Bruce Korb
2015-01-28 18:53 ` Bruce Korb
2015-01-28 20:05 ` Bruce Korb
2015-01-29 14:44 ` Rainer Orth
2015-01-30 19:41 ` Bruce Korb
2015-02-09 11:31 ` Rainer Orth [this message]
2015-02-09 15:55 ` Bruce Korb
-- strict thread matches above, loose matches on Subject: below --
2014-06-26 9:18 Rainer Orth
2014-06-28 19:32 ` Bruce Korb
2014-07-01 10:42 ` Rainer Orth
2014-07-01 11:22 ` Rainer Orth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ydd7fvrz5hs.fsf@lokon.CeBiTec.Uni-Bielefeld.DE \
--to=ro@cebitec.uni-bielefeld.de \
--cc=bkorb@gnu.org \
--cc=bruce.korb@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).