From: Bruno Haible Date: Sun, 23 Feb 2020 13:24:04 +0000 (+0100) Subject: glob, spawn: Use improved '_Restrict_' definition. X-Git-Tag: v1.0~4200 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=e76aacf4675af4aa9591b0a0e9879b375780bd8b;p=gnulib.git glob, spawn: Use improved '_Restrict_' definition. * lib/glob.in.h (_Restrict_): Use same definition as in lib/regex.h. * lib/spawn.in.h (_Restrict_, _Restrict_arr_): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 5b5b35d227..d26227b22c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-02-23 Bruno Haible + + glob, spawn: Use improved '_Restrict_' definition. + * lib/glob.in.h (_Restrict_): Use same definition as in lib/regex.h. + * lib/spawn.in.h (_Restrict_, _Restrict_arr_): Likewise. + 2020-02-23 Bruno Haible crypto/gc: Use 'restrict'. diff --git a/lib/glob.in.h b/lib/glob.in.h index 1072588ea0..7061a253a0 100644 --- a/lib/glob.in.h +++ b/lib/glob.in.h @@ -38,16 +38,17 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ -/* GCC 2.95 and later have "__restrict"; C99 compilers have +/* For plain 'restrict', use glibc's __restrict if defined. + Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have "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__) +# if defined __restrict || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) # define _Restrict_ __restrict +# elif 199901L <= __STDC_VERSION__ || defined restrict +# define _Restrict_ restrict # else # define _Restrict_ # endif diff --git a/lib/spawn.in.h b/lib/spawn.in.h index 4878acb8f8..c4dd01aa35 100644 --- a/lib/spawn.in.h +++ b/lib/spawn.in.h @@ -43,28 +43,28 @@ # define __THROW #endif -/* GCC 2.95 and later have "__restrict"; C99 compilers have +/* For plain 'restrict', use glibc's __restrict if defined. + Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have "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__) +# if defined __restrict || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) # define _Restrict_ __restrict +# elif 199901L <= __STDC_VERSION__ || defined restrict +# 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. */ +/* For [restrict], use glibc's __restrict_arr if available. + Otherwise, GCC 3.1 (not in C++ mode) and C99 support [restrict]. */ #ifndef _Restrict_arr_ -# if ((199901L <= __STDC_VERSION__ \ - || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ - && !defined __STRICT_ANSI__)) \ - && !defined __GNUG__) +# ifdef __restrict_arr +# define _Restrict_arr_ __restrict_arr +# elif ((199901L <= __STDC_VERSION__ || 3 < __GNUC__ + (1 <= __GNUC_MINOR__)) \ + && !defined __GNUG__) # define _Restrict_arr_ _Restrict_ # else # define _Restrict_arr_