Re: [libgomp, libiberty, libobjc] Fix gnu11 fallout on Solaris 10+

2014-11-04 Thread Richard Henderson
On 11/03/2014 05:22 PM, Rainer Orth wrote:
 2014-10-22  Rainer Orth  r...@cebitec.uni-bielefeld.de
 
   libobjc:
   * thr.c (_XOPEN_SOURCE): Define as 600.
 
   libiberty:
   * sigsetmask.c (_POSIX_SOURCE): Remove.
 
   libgomp:
   * config/posix/lock.c (_XOPEN_SOURCE) Define as 600.

Ok.


r~



Re: [libgomp, libiberty, libobjc] Fix gnu11 fallout on Solaris 10+

2014-11-03 Thread Rainer Orth
Richard Henderson r...@redhat.com writes:

 On 10/24/2014 01:56 AM, Rainer Orth wrote:
 And even with the _XOPEN_SOURCE business out of the way, there's still
 the question what to do about _POSIX_SOURCE in libiberty/sigsetmask.c.
 Given that it was introduced almost 20 years ago, it may well be
 unnecessary for the systems we still care about.

 Probably.

I've included the following patch in my Solaris 10, 11, and Linux/x86_64
bootstraps for some time now.  I guess the risk of just defining
_XOPEN_SOURCE to 600 is manageable and eventual fallout restricted to
GCC; not sure about the libiberty change, given that it probably
supports far more and older systems than GCC does.

Anyway: ok for mainline?

Thanks.
Rainer


2014-10-22  Rainer Orth  r...@cebitec.uni-bielefeld.de

libobjc:
* thr.c (_XOPEN_SOURCE): Define as 600.

libiberty:
* sigsetmask.c (_POSIX_SOURCE): Remove.

libgomp:
* config/posix/lock.c (_XOPEN_SOURCE) Define as 600.

# HG changeset patch
# Parent 0ae9b18fcb6f31523dd31f1825a3bb540ad84289
Fix gnu11 fallout on Solaris 10+

diff --git a/libgomp/config/posix/lock.c b/libgomp/config/posix/lock.c
--- a/libgomp/config/posix/lock.c
+++ b/libgomp/config/posix/lock.c
@@ -30,8 +30,9 @@
to do better and streamline the locking as well as reduce the size
of the types exported.  */
 
-/* We need Unix98 extensions to get recursive locks.  */
-#define _XOPEN_SOURCE 500
+/* We need UNIX98/XPG5 extensions to get recursive locks.  Request XPG6 since
+   Solaris requires this for C99 and later.  */
+#define _XOPEN_SOURCE 600
 
 #include libgomp.h
 
diff --git a/libiberty/sigsetmask.c b/libiberty/sigsetmask.c
--- a/libiberty/sigsetmask.c
+++ b/libiberty/sigsetmask.c
@@ -15,7 +15,6 @@ be the value @code{1}).
 
 */
 
-#define _POSIX_SOURCE
 #include ansidecl.h
 /* Including sys/types.h seems to be needed by ISC. */
 #include sys/types.h
diff --git a/libobjc/thr.c b/libobjc/thr.c
--- a/libobjc/thr.c
+++ b/libobjc/thr.c
@@ -27,8 +27,9 @@ see the files COPYING3 and COPYING.RUNTI
 #define _LIBOBJC
 /* The line below is needed for declarations of functions such as
pthread_mutexattr_settype, without which gthr-posix.h may fail to
-   compile within libobjc.  */
-#define _XOPEN_SOURCE 500
+   compile within libobjc.  While we only need XPG5 for this, Solaris
+   requires XPG6 for C99 and later.  */
+#define _XOPEN_SOURCE 600
 #include config.h
 #include tconfig.h
 #include coretypes.h

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [libgomp, libiberty, libobjc] Fix gnu11 fallout on Solaris 10+

2014-10-27 Thread Richard Henderson
On 10/24/2014 01:56 AM, Rainer Orth wrote:
 And even with the _XOPEN_SOURCE business out of the way, there's still
 the question what to do about _POSIX_SOURCE in libiberty/sigsetmask.c.
 Given that it was introduced almost 20 years ago, it may well be
 unnecessary for the systems we still care about.

Probably.


r~


Re: [libgomp, libiberty, libobjc] Fix gnu11 fallout on Solaris 10+

2014-10-24 Thread Rainer Orth
Richard Henderson r...@redhat.com writes:

 On 10/22/2014 04:43 AM, Rainer Orth wrote:
 The gnu11 patch broke Solaris 10 and 11 bootstrap: sys/feature_test.h
 has
 
 /*
  * It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
  * using c99.  The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
  * and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
  * or a POSIX.1-2001 application with anything other than a c99 or later
  * compiler.  Therefore, we force an error in both cases.
  */
 #if defined(_STDC_C99)  (defined(__XOPEN_OR_POSIX)  !defined(_XPG6))
 #error Compiler or options invalid for pre-UNIX 03 X/Open applications \
  and pre-2001 POSIX applications
 #elif !defined(_STDC_C99)  \
  (defined(__XOPEN_OR_POSIX)  defined(_XPG6))
 #error Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
  require the use of c99
 #endif
 
 so the headers now error out for any definition of (say) _XOPEN_SOURCE  600.

 Hum.

 Does it hurt us to simply update to 600 everywhere?  If we can, I'd prefer 
 that
 as a solution.  But if that causes more problems than it solves, I'm ok with
 this as a solution.

This certainly depends on what the oldest systems we still support are.
E.g. in Solaris 8 (no longer supported on mainline, just serving as
illustration) sys/feature_test.h we have for XPG5/UNIX 98:

#if (_XOPEN_SOURCE - 0 == 500)
#define _XPG5

Changing _XOPEN_SOURCE to 600 loses this completely.  Same on Solaris 9
(equally no longer supported), and at least some pre-XPG6 systems, I fear.
I cannot tell if we still support any of those, though.

This might not even an issue for the cases as hand: e.g. even Solaris 8
pthread.h defines PTHREAD_MUTEX_RECURSIVE (the reason to define
_XOPEN_SOURCE in libgomp/config/posix/lock.c) unconditionally.

We might as well try and watch out for breakage, given that we are still
in stage1.

 I would like the comments updated to mention the reason for XPG6; just saying
 that Solaris requires it for C99 and later seems sufficient.

Sure, will do once we've decided which route to follow.

And even with the _XOPEN_SOURCE business out of the way, there's still
the question what to do about _POSIX_SOURCE in libiberty/sigsetmask.c.
Given that it was introduced almost 20 years ago, it may well be
unnecessary for the systems we still care about.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [libgomp, libiberty, libobjc] Fix gnu11 fallout on Solaris 10+

2014-10-23 Thread Richard Henderson
On 10/22/2014 04:43 AM, Rainer Orth wrote:
 The gnu11 patch broke Solaris 10 and 11 bootstrap: sys/feature_test.h
 has
 
 /*
  * It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
  * using c99.  The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
  * and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
  * or a POSIX.1-2001 application with anything other than a c99 or later
  * compiler.  Therefore, we force an error in both cases.
  */
 #if defined(_STDC_C99)  (defined(__XOPEN_OR_POSIX)  !defined(_XPG6))
 #error Compiler or options invalid for pre-UNIX 03 X/Open applications \
   and pre-2001 POSIX applications
 #elif !defined(_STDC_C99)  \
   (defined(__XOPEN_OR_POSIX)  defined(_XPG6))
 #error Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
   require the use of c99
 #endif
 
 so the headers now error out for any definition of (say) _XOPEN_SOURCE  600.

Hum.

Does it hurt us to simply update to 600 everywhere?  If we can, I'd prefer that
as a solution.  But if that causes more problems than it solves, I'm ok with
this as a solution.

I would like the comments updated to mention the reason for XPG6; just saying
that Solaris requires it for C99 and later seems sufficient.


r~


Re: [libgomp, libiberty, libobjc] Fix gnu11 fallout on Solaris 10+

2014-10-23 Thread Andrew Pinski
On Wed, Oct 22, 2014 at 4:43 AM, Rainer Orth
r...@cebitec.uni-bielefeld.de wrote:
 The gnu11 patch broke Solaris 10 and 11 bootstrap: sys/feature_test.h
 has

 /*
  * It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
  * using c99.  The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
  * and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
  * or a POSIX.1-2001 application with anything other than a c99 or later
  * compiler.  Therefore, we force an error in both cases.
  */
 #if defined(_STDC_C99)  (defined(__XOPEN_OR_POSIX)  !defined(_XPG6))
 #error Compiler or options invalid for pre-UNIX 03 X/Open applications \
 and pre-2001 POSIX applications
 #elif !defined(_STDC_C99)  \
 (defined(__XOPEN_OR_POSIX)  defined(_XPG6))
 #error Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
 require the use of c99
 #endif

 so the headers now error out for any definition of (say) _XOPEN_SOURCE  600.

 Obviously, the gnu11 patch is going to cause lots of trouble once GCC 5
 is released.

 The following patch handles this situation, using the most conservative
 (and most ugly since using platform-specific code) approach of defining
 the necessary feature test macros only for Solaris.  I suppose the two
 _XOPEN_SOURCE defines (both present from when the code was added) could
 easily be changed to 600 instead; not sure why _POSIX_SOURCE would be
 necessary in sigsetmask.c (also present from day one).

 Anyway, this patch restores bootstrap, as verified on
 i386-pc-solaris2.11 and sparc-sun-solaris2.11.

 Ok for mainline?

 Rainer


 2014-10-22  Rainer Orth  r...@cebitec.uni-bielefeld.de

 libobjc:
 * thr.c (_XOPEN_SOURCE) [__sun__  __svr4__]: Define as 600.

This is fine.

Thanks,
Andrew



 libiberty:
 * sigsetmask.c (_POSIX_C_SOURCE) [__sun__  __svr4__ 
 __STDC_VERSION__ = 200112L]: Define as 200112L.

 libgomp:
 * config/posix/lock.c (_XOPEN_SOURCE) [__sun__  __svr4__]:
 Define as 600.



 --
 -
 Rainer Orth, Center for Biotechnology, Bielefeld University



[libgomp, libiberty, libobjc] Fix gnu11 fallout on Solaris 10+

2014-10-22 Thread Rainer Orth
The gnu11 patch broke Solaris 10 and 11 bootstrap: sys/feature_test.h
has

/*
 * It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
 * using c99.  The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
 * and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
 * or a POSIX.1-2001 application with anything other than a c99 or later
 * compiler.  Therefore, we force an error in both cases.
 */
#if defined(_STDC_C99)  (defined(__XOPEN_OR_POSIX)  !defined(_XPG6))
#error Compiler or options invalid for pre-UNIX 03 X/Open applications \
and pre-2001 POSIX applications
#elif !defined(_STDC_C99)  \
(defined(__XOPEN_OR_POSIX)  defined(_XPG6))
#error Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
require the use of c99
#endif

so the headers now error out for any definition of (say) _XOPEN_SOURCE  600.

Obviously, the gnu11 patch is going to cause lots of trouble once GCC 5
is released.

The following patch handles this situation, using the most conservative
(and most ugly since using platform-specific code) approach of defining
the necessary feature test macros only for Solaris.  I suppose the two
_XOPEN_SOURCE defines (both present from when the code was added) could
easily be changed to 600 instead; not sure why _POSIX_SOURCE would be
necessary in sigsetmask.c (also present from day one).

Anyway, this patch restores bootstrap, as verified on
i386-pc-solaris2.11 and sparc-sun-solaris2.11.

Ok for mainline?

Rainer


2014-10-22  Rainer Orth  r...@cebitec.uni-bielefeld.de

libobjc:
* thr.c (_XOPEN_SOURCE) [__sun__  __svr4__]: Define as 600.

libiberty:
* sigsetmask.c (_POSIX_C_SOURCE) [__sun__  __svr4__ 
__STDC_VERSION__ = 200112L]: Define as 200112L.

libgomp:
* config/posix/lock.c (_XOPEN_SOURCE) [__sun__  __svr4__]:
Define as 600.

# HG changeset patch
# Parent 0dac6e8c4aa188f94c5502cf106a5aa12e266d5b
Fix gnu11 fallout on Solaris 10+

diff --git a/libgomp/config/posix/lock.c b/libgomp/config/posix/lock.c
--- a/libgomp/config/posix/lock.c
+++ b/libgomp/config/posix/lock.c
@@ -31,7 +31,11 @@
of the types exported.  */
 
 /* We need Unix98 extensions to get recursive locks.  */
+#if defined __sun__  defined __svr4__
+#define _XOPEN_SOURCE 600
+#else
 #define _XOPEN_SOURCE 500
+#endif
 
 #include libgomp.h
 
diff --git a/libiberty/sigsetmask.c b/libiberty/sigsetmask.c
--- a/libiberty/sigsetmask.c
+++ b/libiberty/sigsetmask.c
@@ -15,7 +15,12 @@ be the value @code{1}).
 
 */
 
+#if defined __sun__  defined __svr4__  __STDC_VERSION__ = 200112L
+#define _POSIX_C_SOURCE 200112L
+#else
 #define _POSIX_SOURCE
+#endif
+
 #include ansidecl.h
 /* Including sys/types.h seems to be needed by ISC. */
 #include sys/types.h
diff --git a/libobjc/thr.c b/libobjc/thr.c
--- a/libobjc/thr.c
+++ b/libobjc/thr.c
@@ -28,7 +28,11 @@ see the files COPYING3 and COPYING.RUNTI
 /* The line below is needed for declarations of functions such as
pthread_mutexattr_settype, without which gthr-posix.h may fail to
compile within libobjc.  */
+#if defined __sun__  defined __svr4__
+#define _XOPEN_SOURCE 600
+#else
 #define _XOPEN_SOURCE 500
+#endif
 #include config.h
 #include tconfig.h
 #include coretypes.h

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University