bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] patch for AC_GNU_SOURCE on Solaris


From: Paul Eggert
Subject: [Bug-gnulib] patch for AC_GNU_SOURCE on Solaris
Date: 05 Aug 2003 22:17:12 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Nelson H. F. Beebe reported a coreutils build bug in
<http://mail.gnu.org/archive/html/bug-coreutils/2003-08/msg00008.html>
on Solaris 2.9 (sparc) with Sun C 5.5 invoked as 'c89':

> ../lib/timespec.h", line 39: (struct) tag redeclared: timespec
> c89: acomp failed for date.c

The problem is that c89 strictly follows the C89 name space rules, so
it disables common extensions like 'strndup'.  In particular, it
disables 'struct timespec' in some cases but not in others: '#include
<sys/stat.h>' makes 'struct timespec' visible, but '#include <time.h>'
does not.  'configure' does not find 'struct timespec' in <time.h> (or
<sys/time.h>), so 'configure' generates a definition for 'struct
timespec' that collides with the 'struct timespec' defined in
<sys/stat.h>.

We could spend some time hacking on coreutils to make it portable to
pedantic Solaris, but I don't think it's worth the bother.  It's
easier simply to define __EXTENSIONS__, which is the Solaris analog
to _GNU_SOURCE.

We could define a separate macro AC_SOLARIS_EXTENSIONS to do this.
But __EXTENSIONS__ is so very much like _GNU_SOURCE, and it enables
some GNU-compatible extensions in Solaris, so I think it's more
convenient to have AC_GNU_SOURCE define __EXTENSIONS__ as well.
I'd like to do this for gnulib and autoconf, and migrate the
result into autoconf.

Here is a proposed patch, which I tested on Solaris 9 with coreutils.

2003-08-05  Paul Eggert  <address@hidden>

        * m4/gnu-source.m4 (AC_GNU_SOURCE): Define __EXTENSIONS__,
        to enable GNU-compatible extensions for Solaris c89.
        * m4/timespec.m4 (gl_TIMESPEC, jm_CHECK_TYPE_STRUCT_TIMESPEC):
        Require AC_GNU_SOURCE.

Index: m4/gnu-source.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/gnu-source.m4,v
retrieving revision 1.4
diff -p -u -r1.4 gnu-source.m4
--- m4/gnu-source.m4    22 Jun 2002 08:32:40 -0000      1.4
+++ m4/gnu-source.m4    6 Aug 2003 04:51:57 -0000
@@ -5,8 +5,13 @@ AC_DEFUN([AC_GNU_SOURCE],
 [/* Enable GNU extensions on systems that have them.  */
 #ifndef _GNU_SOURCE
 # undef _GNU_SOURCE
+#endif
+/* Enable many GNU extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
 #endif])dnl
 AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
 AC_DEFINE([_GNU_SOURCE])
+AC_DEFINE([__EXTENSIONS__])
 ])
Index: m4/timespec.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/timespec.m4,v
retrieving revision 1.6
diff -p -u -r1.6 timespec.m4
--- m4/timespec.m4      31 Dec 2002 13:43:06 -0000      1.6
+++ m4/timespec.m4      6 Aug 2003 04:51:57 -0000
@@ -1,10 +1,11 @@
-#serial 6
+#serial 7
 
 dnl From Jim Meyering
 
 AC_DEFUN([gl_TIMESPEC],
 [
   dnl Prerequisites of lib/timespec.h.
+  AC_REQUIRE([AC_GNU_SOURCE])
   AC_REQUIRE([AC_HEADER_TIME])
   AC_CHECK_HEADERS_ONCE(sys/time.h)
   jm_CHECK_TYPE_STRUCT_TIMESPEC
@@ -21,6 +22,7 @@ dnl in time.h or sys/time.h.
 
 AC_DEFUN([jm_CHECK_TYPE_STRUCT_TIMESPEC],
 [
+  AC_REQUIRE([AC_GNU_SOURCE])
   AC_REQUIRE([AC_HEADER_TIME])
   AC_CHECK_HEADERS_ONCE(sys/time.h)
   AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]