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: Jim Meyering
Subject: Re: build failures: string.h vs. HP-UX
Date: Sun, 28 Jan 2007 22:30:30 +0100

address@hidden (Bob Proulx) wrote:
> Bob Proulx wrote:
>> That seemed to mostly work.  It is still failing under ia64 though.  I
>> think the compiler there has no support for restrict.  If I define
>> restrict to be nothing to disable it completely then the compilation
>> succeeds.
>> ...
>> So apparently the configure test for a working restrict is not
>> catching this case.
>
> The HP-UX ia64 compiler does support __restrict fine.  The configure
> test is detecting this correctly.  That turns out not to be the
> problem.
>
> The problem is that regex.h is defining "__restrict" to be "restrict"!
> The regex.h code is:
>
>   /* 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
>   # endif
>   #endif
>
> And of course config.h is defining "restrict" to be "__restrict".
>
>   #define restrict __restrict
>
> That combination is obviously not good.

Hi Bob,

Thanks for tracking that down.

I'm inclined to change gnulib's regex.h to use 'restrict', not
'__restrict' and simply remove that #ifndef block.  Gnulib's requirements
regarding the syntax it uses in header files like this are fundamentally
different from those of glibc.  Gnulib requires that each client
application include "config.h" before e.g., this regex.h, while glibc
does not have this luxury.

Of course this means we'd never be able to sync this file back to glibc,
but for a mere header file (even a 600+-line one like that), it's not
a problem.  BTW, there are already over 400 lines worth of diffs
between the latest in gnulib and what's in glibc.

Barring a better proposal, here's how I'll fix it:

        Avoid a compile error from HP-UX's ia64 cc: s/__restrict\>/restrict/
        * lib/regex.h: Use "restrict", not "__restrict", since only the
        former works with 'config.h's "#define restrict ...".
        Problem reported by Bob Proulx.

Index: lib/regex.h
===================================================================
RCS file: /sources/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 28 Jan 2007 21:25:56 -0000
@@ -1,6 +1,6 @@
 /* Definitions for data structures and routines for the regular
    expression library.
-   Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006
+   Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005-2007
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.

@@ -623,18 +623,6 @@ extern char *re_comp (const char *);
 extern int re_exec (const char *);
 # endif
 #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
-# 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.  */
@@ -643,23 +631,23 @@ extern int re_exec (const char *);
       || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__))     \
          && !__STRICT_ANSI__))                                         \
      && !defined __GNUG__)
-# define __restrict_arr __restrict
+# define __restrict_arr restrict
 #else
 # define __restrict_arr
 #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,
+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);





reply via email to

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