bug-gnulib
[Top][All Lists]
Advanced

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

Re: build failures: string.h vs. HP-UX


From: Paul Eggert
Subject: Re: build failures: string.h vs. HP-UX
Date: Sun, 28 Jan 2007 16:38:29 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

address@hidden (Bob Proulx) writes:

> The problem is that regex.h is defining "__restrict" to be "restrict"!
> ...
> And of course config.h is defining "restrict" to be "__restrict".
>
>   #define restrict __restrict
>
> That combination is obviously not good.

Thanks for reporting that.  I installed this, which I hope fixes
things for you.  I suspect other modules have a similar problem, but
let's verify that this fix works first.

2007-01-28  Paul Eggert  <address@hidden>

        * lib/regex.h (_Restrict_): Renamed from __restrict, to avoid
        a circularity problem with HP-UX ia64 reported by Bob Proulx in
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-01/msg00394.html>.
        All uses changed.
        (_Restrict_arr_): Renamed from __restrict_arr, for similar reasons.
        All uses changed.
        * lib/regcomp.c, lib/regexec.c: Change all uses from __restrict
        to _Restrict_.
        * lib/regexec.c (regexec): Declare pmatch with _Restrict_arr_, so that
        the parameter matches the prototype.

Index: lib/regex.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regex.h,v
retrieving revision 1.40
diff -u -p -r1.40 regex.h
--- lib/regex.h 27 Nov 2006 19:41:42 -0000      1.40
+++ lib/regex.h 29 Jan 2007 00:36:54 -0000
@@ -625,41 +625,45 @@ extern int re_exec (const char *);
 #endif

 /* GCC 2.95 and later have "__restrict"; C99 compilers have
-   "restrict", and "configure" may have defined "restrict".  */
-#ifndef __restrict
-# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
-#  if defined restrict || 199901L <= __STDC_VERSION__
-#   define __restrict restrict
-#  else
-#   define __restrict
-#  endif
+   "restrict", and "configure" may have defined "restrict".
+   Other compilers use __restrict, __restrict__, and _Restrict, and
+   'configure' might #define 'restrict' to those words, so pick a
+   different name.  */
+#ifndef _Restrict_
+# if 199901L <= __STDC_VERSION__
+#  define _Restrict_ restrict
+# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
+#  define _Restrict_ __restrict
+# else
+#  define _Restrict_
 # endif
 #endif
 /* gcc 3.1 and up support the [restrict] syntax.  Don't trust
    sys/cdefs.h's definition of __restrict_arr, though, as it
    mishandles gcc -ansi -pedantic.  */
-#undef __restrict_arr
-#if ((199901L <= __STDC_VERSION__                                      \
-      || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__))     \
-         && !__STRICT_ANSI__))                                         \
-     && !defined __GNUG__)
-# define __restrict_arr __restrict
-#else
-# define __restrict_arr
+#ifndef _Restrict_arr_
+# if ((199901L <= __STDC_VERSION__                                     \
+       || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__))    \
+          && !__STRICT_ANSI__))                                        \
+      && !defined __GNUG__)
+#  define _Restrict_arr_ _Restrict_
+# else
+#  define _Restrict_arr_
+# endif
 #endif

 /* POSIX compatibility.  */
-extern int regcomp (regex_t *__restrict __preg,
-                   const char *__restrict __pattern,
+extern int regcomp (regex_t *_Restrict_ __preg,
+                   const char *_Restrict_ __pattern,
                    int __cflags);

-extern int regexec (const regex_t *__restrict __preg,
-                   const char *__restrict __string, size_t __nmatch,
-                   regmatch_t __pmatch[__restrict_arr],
+extern int regexec (const regex_t *_Restrict_ __preg,
+                   const char *_Restrict_ __string, size_t __nmatch,
+                   regmatch_t __pmatch[_Restrict_arr_],
                    int __eflags);

-extern size_t regerror (int __errcode, const regex_t *__restrict __preg,
-                       char *__restrict __errbuf, size_t __errbuf_size);
+extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg,
+                       char *_Restrict_ __errbuf, size_t __errbuf_size);

 extern void regfree (regex_t *__preg);

Index: lib/regcomp.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regcomp.c,v
retrieving revision 1.23
diff -u -p -r1.23 regcomp.c
--- lib/regcomp.c       28 Nov 2006 08:35:51 -0000      1.23
+++ lib/regcomp.c       29 Jan 2007 00:36:54 -0000
@@ -451,8 +451,8 @@ re_compile_fastmap_iter (regex_t *bufp, 

 int
 regcomp (preg, pattern, cflags)
-    regex_t *__restrict preg;
-    const char *__restrict pattern;
+    regex_t *_Restrict_ preg;
+    const char *_Restrict_ pattern;
     int cflags;
 {
   reg_errcode_t ret;
@@ -515,13 +515,13 @@ weak_alias (__regcomp, regcomp)
 size_t
 regerror (errcode, preg, errbuf, errbuf_size)
     int errcode;
-    const regex_t *__restrict preg;
-    char *__restrict errbuf;
+    const regex_t *_Restrict_ preg;
+    char *_Restrict_ errbuf;
     size_t errbuf_size;
 #else /* size_t might promote */
 size_t
-regerror (int errcode, const regex_t *__restrict preg,
-         char *__restrict errbuf, size_t errbuf_size)
+regerror (int errcode, const regex_t *_Restrict_ preg,
+         char *_Restrict_ errbuf, size_t errbuf_size)
 #endif
 {
   const char *msg;
Index: lib/regexec.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/regexec.c,v
retrieving revision 1.23
diff -u -p -r1.23 regexec.c
--- lib/regexec.c       27 Nov 2006 07:15:26 -0000      1.23
+++ lib/regexec.c       29 Jan 2007 00:36:54 -0000
@@ -221,10 +221,10 @@ static reg_errcode_t extend_buffers (re_

 int
 regexec (preg, string, nmatch, pmatch, eflags)
-    const regex_t *__restrict preg;
-    const char *__restrict string;
+    const regex_t *_Restrict_ preg;
+    const char *_Restrict_ string;
     size_t nmatch;
-    regmatch_t pmatch[];
+    regmatch_t pmatch[_Restrict_arr_];
     int eflags;
 {
   reg_errcode_t err;
@@ -267,8 +267,8 @@ __typeof__ (__regexec) __compat_regexec;

 int
 attribute_compat_text_section
-__compat_regexec (const regex_t *__restrict preg,
-                 const char *__restrict string, size_t nmatch,
+__compat_regexec (const regex_t *_Restrict_ preg,
+                 const char *_Restrict_ string, size_t nmatch,
                  regmatch_t pmatch[], int eflags)
 {
   return regexec (preg, string, nmatch, pmatch,




reply via email to

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