Paul Eggert wrote: > > Here's a proposed patch. > > That looks good as far as it goes,
OK, here's a revised patch. Avoids the #ifndef now, and includes some tests/*.c files. > but while we're at it, > shouldn't we use a consistent naming convention? > It's confusing that one .h file uses _GL_ATTRIBUTE_NORETURN and > another uses ATTRIBUTE_NORETURN, for the same notion. Good point. Here's a patch to rename these macros, so that they use the _GL_ prefix which we agreed a couple of months ago is the least risky. Objections to these patches? Jim? Paul? > If nobody objects, I'd like to apply a similar patch > to the C files as well, if only to forestall people > cutting-and-pasting wrong code from them in the future. You're welcome! Bruno -- In memoriam Alexander Samoylovich <http://en.wikipedia.org/wiki/Alexander_Samoylovich>
From 881a45347636c2895d1991ed6483bfdab39553fc Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 13 Feb 2011 23:21:20 +0100 Subject: [PATCH 1/2] Don't interfere with a program's definition of __attribute__. * lib/argp.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (argp_error, __argp_error, argp_failure, __argp_failure): Use it. * lib/argp-fmtstream.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (__argp_fmtstream_printf, argp_fmtstream_printf): Use it. * lib/argp-help.c (hol_entry_long_iterate): Use __attribute__ only for GCC 3 or newer. * lib/error.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (error, error_at_line): Use it. * lib/hash.h (__attribute__): Remove definition. (ATTRIBUTE_WUR): Update definition. Define always. * lib/openat.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/sigpipe-die.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/vasnprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (asnprintf, vasnprintf): Use it. * lib/xalloc.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. (ATTRIBUTE_MALLOC, ATTRIBUTE_ALLOC_SIZE): Define always. * lib/xmemdup0.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/xprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (xprintf, xvprintf, xfprintf, xvfprintf): Use it. * lib/xstrtol.h (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * lib/xvasprintf.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. (xasprintf, xvasprintf): Use it. * tests/test-argmatch.c (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. * tests/test-exclude.c (__attribute__): Remove definition. (ATTRIBUTE_NORETURN): Update definition. Define always. Reported by Paul Eggert. --- ChangeLog | 42 ++++++++++++++++++++++++++++++++++++++++++ lib/argp-fmtstream.h | 14 +++++++------- lib/argp-help.c | 2 ++ lib/argp.h | 18 +++++++++--------- lib/error.h | 14 +++++++------- lib/hash.h | 13 +++++-------- lib/openat.h | 10 +++------- lib/sigpipe-die.h | 10 +++------- lib/vasnprintf.h | 14 +++++++------- lib/xalloc.h | 30 +++++++++++------------------- lib/xmemdup0.h | 10 +++------- lib/xprintf.h | 18 +++++++++--------- lib/xstrtol.h | 10 +++------- lib/xvasprintf.h | 14 +++++++------- tests/test-argmatch.c | 12 ++++-------- tests/test-exclude.c | 11 ++++------- 16 files changed, 126 insertions(+), 116 deletions(-) diff --git a/ChangeLog b/ChangeLog index 12b6b5e..8a363a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,47 @@ 2011-02-13 Bruno Haible <br...@clisp.org> + Don't interfere with a program's definition of __attribute__. + * lib/argp.h (__attribute__): Remove definition. + (_GL_ATTRIBUTE_FORMAT): New macro. + (argp_error, __argp_error, argp_failure, __argp_failure): Use it. + * lib/argp-fmtstream.h (__attribute__): Remove definition. + (_GL_ATTRIBUTE_FORMAT): New macro. + (__argp_fmtstream_printf, argp_fmtstream_printf): Use it. + * lib/argp-help.c (hol_entry_long_iterate): Use __attribute__ only for + GCC 3 or newer. + * lib/error.h (__attribute__): Remove definition. + (_GL_ATTRIBUTE_FORMAT): New macro. + (error, error_at_line): Use it. + * lib/hash.h (__attribute__): Remove definition. + (ATTRIBUTE_WUR): Update definition. Define always. + * lib/openat.h (__attribute__): Remove definition. + (ATTRIBUTE_NORETURN): Update definition. Define always. + * lib/sigpipe-die.h (__attribute__): Remove definition. + (ATTRIBUTE_NORETURN): Update definition. Define always. + * lib/vasnprintf.h (__attribute__): Remove definition. + (_GL_ATTRIBUTE_FORMAT): New macro. + (asnprintf, vasnprintf): Use it. + * lib/xalloc.h (__attribute__): Remove definition. + (ATTRIBUTE_NORETURN): Update definition. Define always. + (ATTRIBUTE_MALLOC, ATTRIBUTE_ALLOC_SIZE): Define always. + * lib/xmemdup0.h (__attribute__): Remove definition. + (ATTRIBUTE_NORETURN): Update definition. Define always. + * lib/xprintf.h (__attribute__): Remove definition. + (_GL_ATTRIBUTE_FORMAT): New macro. + (xprintf, xvprintf, xfprintf, xvfprintf): Use it. + * lib/xstrtol.h (__attribute__): Remove definition. + (ATTRIBUTE_NORETURN): Update definition. Define always. + * lib/xvasprintf.h (__attribute__): Remove definition. + (_GL_ATTRIBUTE_FORMAT): New macro. + (xasprintf, xvasprintf): Use it. + * tests/test-argmatch.c (__attribute__): Remove definition. + (ATTRIBUTE_NORETURN): Update definition. Define always. + * tests/test-exclude.c (__attribute__): Remove definition. + (ATTRIBUTE_NORETURN): Update definition. Define always. + Reported by Paul Eggert. + +2011-02-13 Bruno Haible <br...@clisp.org> + mbrtowc: Work around native Windows bug. * m4/mbrtowc.m4 (gl_MBRTOWC_RETVAL): Detect native Windows bug. Use the guess when no suitable locale for testing was found. diff --git a/lib/argp-fmtstream.h b/lib/argp-fmtstream.h index 1642b0f..f664254 100644 --- a/lib/argp-fmtstream.h +++ b/lib/argp-fmtstream.h @@ -28,16 +28,16 @@ #include <string.h> #include <unistd.h> -#ifndef __attribute__ /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable __attribute__ only if these are supported too, because + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __attribute__(Spec) /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif #if (_LIBC - 0 && !defined (USE_IN_LIBIO)) \ @@ -128,10 +128,10 @@ extern void argp_fmtstream_free (argp_fmtstream_t __fs); extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs, const char *__fmt, ...) - __attribute__ ((__format__ (printf, 2, 3))); + _GL_ATTRIBUTE_FORMAT ((printf, 2, 3)); extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs, const char *__fmt, ...) - __attribute__ ((__format__ (printf, 2, 3))); + _GL_ATTRIBUTE_FORMAT ((printf, 2, 3)); #if _LIBC || !defined __OPTIMIZE__ extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch); diff --git a/lib/argp-help.c b/lib/argp-help.c index 99f4a65..48c37a9 100644 --- a/lib/argp-help.c +++ b/lib/argp-help.c @@ -570,7 +570,9 @@ hol_entry_short_iterate (const struct hol_entry *entry, } static inline int +#if __GNUC__ >= 3 __attribute__ ((always_inline)) +#endif hol_entry_long_iterate (const struct hol_entry *entry, int (*func)(const struct argp_option *opt, const struct argp_option *real, diff --git a/lib/argp.h b/lib/argp.h index dfb88d7..c0483ab 100644 --- a/lib/argp.h +++ b/lib/argp.h @@ -34,16 +34,16 @@ # define __NTH(fct) fct __THROW #endif -#ifndef __attribute__ /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable __attribute__ only if these are supported too, because + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __attribute__(Spec) /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif /* GCC 2.95 and later have "__restrict"; C99 compilers have @@ -530,10 +530,10 @@ extern void __argp_usage (const struct argp_state *__state); message, then exit (1). */ extern void argp_error (const struct argp_state *__restrict __state, const char *__restrict __fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3)); extern void __argp_error (const struct argp_state *__restrict __state, const char *__restrict __fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3)); /* Similar to the standard gnu error-reporting function error(), but will respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print @@ -546,11 +546,11 @@ extern void __argp_error (const struct argp_state *__restrict __state, extern void argp_failure (const struct argp_state *__restrict __state, int __status, int __errnum, const char *__restrict __fmt, ...) - __attribute__ ((__format__ (__printf__, 4, 5))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5)); extern void __argp_failure (const struct argp_state *__restrict __state, int __status, int __errnum, const char *__restrict __fmt, ...) - __attribute__ ((__format__ (__printf__, 4, 5))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5)); #if _LIBC || !defined __USE_EXTERN_INLINES /* Returns true if the option OPT is a valid short option. */ diff --git a/lib/error.h b/lib/error.h index 9a2a566..80f81bc 100644 --- a/lib/error.h +++ b/lib/error.h @@ -19,16 +19,16 @@ #ifndef _ERROR_H #define _ERROR_H 1 -#ifndef __attribute__ /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable __attribute__ only if these are supported too, because + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __attribute__(Spec) /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif #ifdef __cplusplus @@ -40,11 +40,11 @@ extern "C" { If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ extern void error (int __status, int __errnum, const char *__format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); extern void error_at_line (int __status, int __errnum, const char *__fname, unsigned int __lineno, const char *__format, ...) - __attribute__ ((__format__ (__printf__, 5, 6))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6)); /* If NULL, error will flush stdout, then print on stderr the program name, a colon and a space. Otherwise, error will call this diff --git a/lib/hash.h b/lib/hash.h index 9c2f5b7..19671f6 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -27,15 +27,12 @@ # include <stdio.h> # include <stdbool.h> -/* The warn_unused_result attribute appeared first in gcc-3.4.0 */ -# ifndef __attribute__ -# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4) -# define __attribute__(x) -# endif -# endif - -# ifndef ATTRIBUTE_WUR +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The warn_unused_result attribute appeared first in gcc-3.4.0. */ +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) # define ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__)) +# else +# define ATTRIBUTE_WUR /* empty */ # endif typedef size_t (*Hash_hasher) (const void *, size_t); diff --git a/lib/openat.h b/lib/openat.h index dd0bb01..9cf7e0f 100644 --- a/lib/openat.h +++ b/lib/openat.h @@ -27,14 +27,10 @@ #include <unistd.h> #include <stdbool.h> -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) /* empty */ -# endif -#endif - -#ifndef ATTRIBUTE_NORETURN +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#else +# define ATTRIBUTE_NORETURN /* empty */ #endif #if !HAVE_OPENAT diff --git a/lib/sigpipe-die.h b/lib/sigpipe-die.h index e725c16..4cbd920 100644 --- a/lib/sigpipe-die.h +++ b/lib/sigpipe-die.h @@ -47,14 +47,10 @@ extern "C" { #endif -# ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif -# endif - -# ifndef ATTRIBUTE_NORETURN +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# else +# define ATTRIBUTE_NORETURN /* empty */ # endif /* Emit an error message indicating a SIGPIPE signal, and terminate the diff --git a/lib/vasnprintf.h b/lib/vasnprintf.h index 3d00df9..0ab7d19 100644 --- a/lib/vasnprintf.h +++ b/lib/vasnprintf.h @@ -24,16 +24,16 @@ /* Get size_t. */ #include <stddef.h> -#ifndef __attribute__ /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable __attribute__ only if these are supported too, because + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __attribute__(Spec) /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif #ifdef __cplusplus @@ -69,9 +69,9 @@ extern "C" { # define vasnprintf rpl_vasnprintf #endif extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4)); extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 3, 0))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0)); #ifdef __cplusplus } diff --git a/lib/xalloc.h b/lib/xalloc.h index aaec116..30823b7 100644 --- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -26,30 +26,22 @@ extern "C" { # endif -# ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif -# endif - -# ifndef ATTRIBUTE_NORETURN +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# else +# define ATTRIBUTE_NORETURN /* empty */ # endif -# ifndef ATTRIBUTE_MALLOC -# if __GNUC__ >= 3 -# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) -# else -# define ATTRIBUTE_MALLOC -# endif +# if __GNUC__ >= 3 +# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define ATTRIBUTE_MALLOC # endif -# ifndef ATTRIBUTE_ALLOC_SIZE -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) -# else -# define ATTRIBUTE_ALLOC_SIZE(args) -# endif +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) +# else +# define ATTRIBUTE_ALLOC_SIZE(args) # endif /* This function is always triggered when memory is exhausted. diff --git a/lib/xmemdup0.h b/lib/xmemdup0.h index 8b50072..ff118a6 100644 --- a/lib/xmemdup0.h +++ b/lib/xmemdup0.h @@ -25,14 +25,10 @@ extern "C" { # endif -# ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif -# endif - -# ifndef ATTRIBUTE_NORETURN +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# else +# define ATTRIBUTE_NORETURN /* empty */ # endif /* This function is always triggered when memory is exhausted. diff --git a/lib/xprintf.h b/lib/xprintf.h index 9dd0443..ca48ce7 100644 --- a/lib/xprintf.h +++ b/lib/xprintf.h @@ -20,26 +20,26 @@ #include <stdarg.h> #include <stdio.h> -#ifndef __attribute__ /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable __attribute__ only if these are supported too, because + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __attribute__(Spec) /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif extern int xprintf (char const *restrict format, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 2)); extern int xvprintf (char const *restrict format, va_list args) - __attribute__ ((__format__ (__printf__, 1, 0))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 0)); extern int xfprintf (FILE *restrict stream, char const *restrict format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3)); extern int xvfprintf (FILE *restrict stream, char const *restrict format, va_list args) - __attribute__ ((__format__ (__printf__, 2, 0))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 0)); #endif diff --git a/lib/xstrtol.h b/lib/xstrtol.h index 530afc9..f91d864 100644 --- a/lib/xstrtol.h +++ b/lib/xstrtol.h @@ -51,14 +51,10 @@ _DECLARE_XSTRTOL (xstrtoll, long long int) _DECLARE_XSTRTOL (xstrtoull, unsigned long long int) #endif -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) -# endif -#endif - -#ifndef ATTRIBUTE_NORETURN +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#else +# define ATTRIBUTE_NORETURN /* empty */ #endif /* Report an error for an invalid integer in an option argument. diff --git a/lib/xvasprintf.h b/lib/xvasprintf.h index 1ac3342..197c9ea 100644 --- a/lib/xvasprintf.h +++ b/lib/xvasprintf.h @@ -20,16 +20,16 @@ /* Get va_list. */ #include <stdarg.h> -#ifndef __attribute__ /* The __attribute__ feature is available in gcc versions 2.5 and later. The __-protected variants of the attributes 'format' and 'printf' are accepted by gcc versions 2.6.4 (effectively 2.7) and later. - We enable __attribute__ only if these are supported too, because + We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because gnulib and libintl do '#define printf __printf__' when they override the 'printf' function. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) -# define __attribute__(Spec) /* empty */ -# endif +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +#else +# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */ #endif #ifdef __cplusplus @@ -44,9 +44,9 @@ extern "C" { - [EILSEQ] error during conversion between wide and multibyte characters, return NULL. */ extern char *xasprintf (const char *format, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 2)); extern char *xvasprintf (const char *format, va_list args) - __attribute__ ((__format__ (__printf__, 1, 0))); + _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 0)); #ifdef __cplusplus } diff --git a/tests/test-argmatch.c b/tests/test-argmatch.c index 4ec5fec..57ec0d5 100644 --- a/tests/test-argmatch.c +++ b/tests/test-argmatch.c @@ -29,15 +29,11 @@ /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in <config.h>, and thus must link with a definition of that function. Provide it here. */ #ifdef ARGMATCH_DIE_DECL -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) /* empty */ +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# else +# define ATTRIBUTE_NORETURN /* empty */ # endif -#endif - -#ifndef ATTRIBUTE_NORETURN -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) -#endif ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN; ARGMATCH_DIE_DECL { exit (1); } diff --git a/tests/test-exclude.c b/tests/test-exclude.c index eed4b28..bab4676 100644 --- a/tests/test-exclude.c +++ b/tests/test-exclude.c @@ -63,16 +63,13 @@ ARGMATCH_VERIFY (exclude_keywords, exclude_flags); /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in <config.h>, and thus must link with a definition of that function. Provide it here. */ #ifdef ARGMATCH_DIE_DECL -#ifndef __attribute__ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) -# define __attribute__(x) /* empty */ +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# else +# define ATTRIBUTE_NORETURN /* empty */ # endif #endif -#ifndef ATTRIBUTE_NORETURN -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) -#endif - ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN; ARGMATCH_DIE_DECL { exit (1); } #endif -- 1.6.3.2
From 59635b60f5829d7d1794a8e7f166bc6e7d12e1f2 Mon Sep 17 00:00:00 2001 From: Bruno Haible <br...@clisp.org> Date: Sun, 13 Feb 2011 23:44:28 +0100 Subject: [PATCH 2/2] Consistent macro naming for macros that use GCC __attribute__. * lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Renamed from _ATTRIBUTE_NONNULL_. * lib/ino-map.h (_GL_ATTRIBUTE_NONNULL): Likewise. * lib/hash.h (_GL_ATTRIBUTE_WUR): Renamed from ATTRIBUTE_WUR. * lib/ignore-value.h (_GL_ATTRIBUTE_DEPRECATED): Renamed from ATTRIBUTE_DEPRECATED. * lib/openat.h (_GL_ATTRIBUTE_NORETURN): Renamed from ATTRIBUTE_NORETURN. * lib/sigpipe-die.h (_GL_ATTRIBUTE_NORETURN): Likewise. * lib/xmemdup0.h (_GL_ATTRIBUTE_NORETURN): Likewise. * lib/xstrtol.h (_GL_ATTRIBUTE_NORETURN): Likewise. * lib/xalloc.h (_GL_ATTRIBUTE_NORETURN): Likewise. (_GL_ATTRIBUTE_MALLOC): Renamed from ATTRIBUTE_MALLOC. (_GL_ATTRIBUTE_ALLOC_SIZE): Renamed from ATTRIBUTE_ALLOC_SIZE. * lib/version-etc.h (_GL_ATTRIBUTE_SENTINEL): Renamed from ATTRIBUTE_SENTINEL. * lib/safe-alloc.h (_GL_ATTRIBUTE_RETURN_CHECK): Renamed from ATTRIBUTE_RETURN_CHECK. * tests/test-ignore-value.c (_GL_ATTRIBUTE_RETURN_CHECK): Likewise. * tests/test-argmatch.c (_GL_ATTRIBUTE_NORETURN): Renamed from ATTRIBUTE_NORETURN. * tests/test-exclude.c (_GL_ATTRIBUTE_NORETURN): Likewise. Reported by Paul Eggert. --- ChangeLog | 27 +++++++++++++++++++++++++++ lib/di-set.h | 12 ++++++------ lib/hash.h | 10 +++++----- lib/ignore-value.h | 8 ++++---- lib/ino-map.h | 10 +++++----- lib/openat.h | 8 ++++---- lib/safe-alloc.h | 10 +++++----- lib/sigpipe-die.h | 6 +++--- lib/version-etc.h | 8 ++++---- lib/xalloc.h | 38 +++++++++++++++++++------------------- lib/xmemdup0.h | 6 +++--- lib/xstrtol.h | 6 +++--- tests/test-argmatch.c | 6 +++--- tests/test-exclude.c | 6 +++--- tests/test-ignore-value.c | 16 ++++++++-------- 15 files changed, 102 insertions(+), 75 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a363a5..e81347c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,32 @@ 2011-02-13 Bruno Haible <br...@clisp.org> + Consistent macro naming for macros that use GCC __attribute__. + * lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Renamed from + _ATTRIBUTE_NONNULL_. + * lib/ino-map.h (_GL_ATTRIBUTE_NONNULL): Likewise. + * lib/hash.h (_GL_ATTRIBUTE_WUR): Renamed from ATTRIBUTE_WUR. + * lib/ignore-value.h (_GL_ATTRIBUTE_DEPRECATED): Renamed from + ATTRIBUTE_DEPRECATED. + * lib/openat.h (_GL_ATTRIBUTE_NORETURN): Renamed from + ATTRIBUTE_NORETURN. + * lib/sigpipe-die.h (_GL_ATTRIBUTE_NORETURN): Likewise. + * lib/xmemdup0.h (_GL_ATTRIBUTE_NORETURN): Likewise. + * lib/xstrtol.h (_GL_ATTRIBUTE_NORETURN): Likewise. + * lib/xalloc.h (_GL_ATTRIBUTE_NORETURN): Likewise. + (_GL_ATTRIBUTE_MALLOC): Renamed from ATTRIBUTE_MALLOC. + (_GL_ATTRIBUTE_ALLOC_SIZE): Renamed from ATTRIBUTE_ALLOC_SIZE. + * lib/version-etc.h (_GL_ATTRIBUTE_SENTINEL): Renamed from + ATTRIBUTE_SENTINEL. + * lib/safe-alloc.h (_GL_ATTRIBUTE_RETURN_CHECK): Renamed from + ATTRIBUTE_RETURN_CHECK. + * tests/test-ignore-value.c (_GL_ATTRIBUTE_RETURN_CHECK): Likewise. + * tests/test-argmatch.c (_GL_ATTRIBUTE_NORETURN): Renamed from + ATTRIBUTE_NORETURN. + * tests/test-exclude.c (_GL_ATTRIBUTE_NORETURN): Likewise. + Reported by Paul Eggert. + +2011-02-13 Bruno Haible <br...@clisp.org> + Don't interfere with a program's definition of __attribute__. * lib/argp.h (__attribute__): Remove definition. (_GL_ATTRIBUTE_FORMAT): New macro. diff --git a/lib/di-set.h b/lib/di-set.h index 318e9ae..abc3161 100644 --- a/lib/di-set.h +++ b/lib/di-set.h @@ -3,17 +3,17 @@ # include <sys/types.h> -# undef _ATTRIBUTE_NONNULL_ +# undef _GL_ATTRIBUTE_NONNULL # if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__ -# define _ATTRIBUTE_NONNULL_(m) __attribute__ ((__nonnull__ (m))) +# define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m))) # else -# define _ATTRIBUTE_NONNULL_(m) +# define _GL_ATTRIBUTE_NONNULL(m) # endif struct di_set *di_set_alloc (void); -int di_set_insert (struct di_set *, dev_t, ino_t) _ATTRIBUTE_NONNULL_ (1); -void di_set_free (struct di_set *) _ATTRIBUTE_NONNULL_ (1); +int di_set_insert (struct di_set *, dev_t, ino_t) _GL_ATTRIBUTE_NONNULL (1); +void di_set_free (struct di_set *) _GL_ATTRIBUTE_NONNULL (1); int di_set_lookup (struct di_set *dis, dev_t dev, ino_t ino) - _ATTRIBUTE_NONNULL_ (1); + _GL_ATTRIBUTE_NONNULL (1); #endif diff --git a/lib/hash.h b/lib/hash.h index 19671f6..9f694be 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -30,9 +30,9 @@ /* The __attribute__ feature is available in gcc versions 2.5 and later. The warn_unused_result attribute appeared first in gcc-3.4.0. */ # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# define ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__)) +# define _GL_ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__)) # else -# define ATTRIBUTE_WUR /* empty */ +# define _GL_ATTRIBUTE_WUR /* empty */ # endif typedef size_t (*Hash_hasher) (const void *, size_t); @@ -78,13 +78,13 @@ size_t hash_string (const char *, size_t); void hash_reset_tuning (Hash_tuning *); Hash_table *hash_initialize (size_t, const Hash_tuning *, Hash_hasher, Hash_comparator, - Hash_data_freer) ATTRIBUTE_WUR; + Hash_data_freer) _GL_ATTRIBUTE_WUR; void hash_clear (Hash_table *); void hash_free (Hash_table *); /* Insertion and deletion. */ -bool hash_rehash (Hash_table *, size_t) ATTRIBUTE_WUR; -void *hash_insert (Hash_table *, const void *) ATTRIBUTE_WUR; +bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_WUR; +void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_WUR; int hash_insert0 (Hash_table *table, const void *entry, const void **matched_ent); void *hash_delete (Hash_table *, const void *); diff --git a/lib/ignore-value.h b/lib/ignore-value.h index 5e683bb..f021a1a 100644 --- a/lib/ignore-value.h +++ b/lib/ignore-value.h @@ -35,13 +35,13 @@ #ifndef _GL_IGNORE_VALUE_H # define _GL_IGNORE_VALUE_H -# ifndef ATTRIBUTE_DEPRECATED +# ifndef _GL_ATTRIBUTE_DEPRECATED /* The __attribute__((__deprecated__)) feature is available in gcc versions 3.1 and newer. */ # if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1) -# define ATTRIBUTE_DEPRECATED /* empty */ +# define _GL_ATTRIBUTE_DEPRECATED /* empty */ # else -# define ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) +# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) # endif # endif @@ -56,7 +56,7 @@ /* ignore_value works for scalars, pointers and aggregates; deprecate ignore_ptr. */ -static inline void ATTRIBUTE_DEPRECATED +static inline void _GL_ATTRIBUTE_DEPRECATED ignore_ptr (void *p) { (void) p; } /* deprecated: use ignore_value */ #endif diff --git a/lib/ino-map.h b/lib/ino-map.h index e060af0..b742291 100644 --- a/lib/ino-map.h +++ b/lib/ino-map.h @@ -3,17 +3,17 @@ # include <sys/types.h> -# undef _ATTRIBUTE_NONNULL_ +# undef _GL_ATTRIBUTE_NONNULL # if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__ -# define _ATTRIBUTE_NONNULL_(m) __attribute__ ((__nonnull__ (m))) +# define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m))) # else -# define _ATTRIBUTE_NONNULL_(m) +# define _GL_ATTRIBUTE_NONNULL(m) # endif # define INO_MAP_INSERT_FAILURE ((size_t) -1) struct ino_map *ino_map_alloc (size_t); -void ino_map_free (struct ino_map *) _ATTRIBUTE_NONNULL_ (1); -size_t ino_map_insert (struct ino_map *, ino_t) _ATTRIBUTE_NONNULL_ (1); +void ino_map_free (struct ino_map *) _GL_ATTRIBUTE_NONNULL (1); +size_t ino_map_insert (struct ino_map *, ino_t) _GL_ATTRIBUTE_NONNULL (1); #endif diff --git a/lib/openat.h b/lib/openat.h index 9cf7e0f..5cb1866 100644 --- a/lib/openat.h +++ b/lib/openat.h @@ -28,9 +28,9 @@ #include <stdbool.h> #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) #else -# define ATTRIBUTE_NORETURN /* empty */ +# define _GL_ATTRIBUTE_NORETURN /* empty */ #endif #if !HAVE_OPENAT @@ -47,8 +47,8 @@ bool openat_needs_fchdir (void); #endif -void openat_restore_fail (int) ATTRIBUTE_NORETURN; -void openat_save_fail (int) ATTRIBUTE_NORETURN; +void openat_restore_fail (int) _GL_ATTRIBUTE_NORETURN; +void openat_save_fail (int) _GL_ATTRIBUTE_NORETURN; /* Using these function names makes application code slightly more readable than it would be with diff --git a/lib/safe-alloc.h b/lib/safe-alloc.h index 1b5ed15..269d1bf 100644 --- a/lib/safe-alloc.h +++ b/lib/safe-alloc.h @@ -31,22 +31,22 @@ # endif #endif -# ifndef ATTRIBUTE_RETURN_CHECK +# ifndef _GL_ATTRIBUTE_RETURN_CHECK # if __GNUC_PREREQ (3, 4) -# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__)) +# define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__)) # else -# define ATTRIBUTE_RETURN_CHECK +# define _GL_ATTRIBUTE_RETURN_CHECK # endif # endif /* Don't call these directly - use the macros below */ int safe_alloc_alloc_n (void *ptrptr, size_t size, size_t count, int zeroed) - ATTRIBUTE_RETURN_CHECK; + _GL_ATTRIBUTE_RETURN_CHECK; int safe_alloc_realloc_n (void *ptrptr, size_t size, size_t count) - ATTRIBUTE_RETURN_CHECK; + _GL_ATTRIBUTE_RETURN_CHECK; /** * ALLOC: diff --git a/lib/sigpipe-die.h b/lib/sigpipe-die.h index 4cbd920..91565bc 100644 --- a/lib/sigpipe-die.h +++ b/lib/sigpipe-die.h @@ -48,14 +48,14 @@ extern "C" { # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # else -# define ATTRIBUTE_NORETURN /* empty */ +# define _GL_ATTRIBUTE_NORETURN /* empty */ # endif /* Emit an error message indicating a SIGPIPE signal, and terminate the process with an error code. */ -extern void sigpipe_die (void) ATTRIBUTE_NORETURN; +extern void sigpipe_die (void) _GL_ATTRIBUTE_NORETURN; /* Install a SIGPIPE handler that invokes PREPARE_DIE and then emits an error message and exits. PREPARE_DIE may be NULL, meaning a no-op. */ diff --git a/lib/version-etc.h b/lib/version-etc.h index bddaf0a..a9b313d 100644 --- a/lib/version-etc.h +++ b/lib/version-etc.h @@ -23,11 +23,11 @@ # include <stdio.h> /* The `sentinel' attribute was added in gcc 4.0. */ -#ifndef ATTRIBUTE_SENTINEL +#ifndef _GL_ATTRIBUTE_SENTINEL # if 4 <= __GNUC__ -# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) +# define _GL_ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) # else -# define ATTRIBUTE_SENTINEL /* empty */ +# define _GL_ATTRIBUTE_SENTINEL /* empty */ # endif #endif @@ -70,7 +70,7 @@ extern void version_etc (FILE *stream, const char *command_name, const char *package, const char *version, /* const char *author1, ..., NULL */ ...) - ATTRIBUTE_SENTINEL; + _GL_ATTRIBUTE_SENTINEL; /* Display the usual `Report bugs to' stanza */ extern void emit_bug_reporting_address (void); diff --git a/lib/xalloc.h b/lib/xalloc.h index 30823b7..86b9b3e 100644 --- a/lib/xalloc.h +++ b/lib/xalloc.h @@ -27,21 +27,21 @@ extern "C" { # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # else -# define ATTRIBUTE_NORETURN /* empty */ +# define _GL_ATTRIBUTE_NORETURN /* empty */ # endif # if __GNUC__ >= 3 -# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) # else -# define ATTRIBUTE_MALLOC +# define _GL_ATTRIBUTE_MALLOC # endif # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) # else -# define ATTRIBUTE_ALLOC_SIZE(args) +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) # endif /* This function is always triggered when memory is exhausted. @@ -49,21 +49,21 @@ extern "C" { or by using gnulib's xalloc-die module. This is the function to call when one wants the program to die because of a memory allocation failure. */ -extern void xalloc_die (void) ATTRIBUTE_NORETURN; +extern void xalloc_die (void) _GL_ATTRIBUTE_NORETURN; void *xmalloc (size_t s) - ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1)); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); void *xzalloc (size_t s) - ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1)); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); void *xcalloc (size_t n, size_t s) - ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1, 2)); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); void *xrealloc (void *p, size_t s) - ATTRIBUTE_ALLOC_SIZE ((2)); + _GL_ATTRIBUTE_ALLOC_SIZE ((2)); void *x2realloc (void *p, size_t *pn); void *xmemdup (void const *p, size_t s) - ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((2)); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2)); char *xstrdup (char const *str) - ATTRIBUTE_MALLOC; + _GL_ATTRIBUTE_MALLOC; /* Return 1 if an array of N objects, each of size S, cannot exist due to size arithmetic overflow. S must be positive and N must be @@ -111,12 +111,12 @@ char *xstrdup (char const *str) # define static_inline static inline # else void *xnmalloc (size_t n, size_t s) - ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1, 2)); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); void *xnrealloc (void *p, size_t n, size_t s) - ATTRIBUTE_ALLOC_SIZE ((2, 3)); + _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); void *x2nrealloc (void *p, size_t *pn, size_t s); char *xcharalloc (size_t n) - ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1)); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); # endif # ifdef static_inline @@ -125,7 +125,7 @@ char *xcharalloc (size_t n) dynamically, with error checking. S must be nonzero. */ static_inline void *xnmalloc (size_t n, size_t s) - ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1, 2)); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2)); static_inline void * xnmalloc (size_t n, size_t s) { @@ -138,7 +138,7 @@ xnmalloc (size_t n, size_t s) objects each of S bytes, with error checking. S must be nonzero. */ static_inline void *xnrealloc (void *p, size_t n, size_t s) - ATTRIBUTE_ALLOC_SIZE ((2, 3)); + _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)); static_inline void * xnrealloc (void *p, size_t n, size_t s) { @@ -240,7 +240,7 @@ x2nrealloc (void *p, size_t *pn, size_t s) except it returns char *. */ static_inline char *xcharalloc (size_t n) - ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1)); + _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1)); static_inline char * xcharalloc (size_t n) { diff --git a/lib/xmemdup0.h b/lib/xmemdup0.h index ff118a6..8a64e70 100644 --- a/lib/xmemdup0.h +++ b/lib/xmemdup0.h @@ -26,9 +26,9 @@ extern "C" { # endif # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # else -# define ATTRIBUTE_NORETURN /* empty */ +# define _GL_ATTRIBUTE_NORETURN /* empty */ # endif /* This function is always triggered when memory is exhausted. @@ -36,7 +36,7 @@ extern "C" { or by using gnulib's xalloc-die module. This is the function to call when one wants the program to die because of a memory allocation failure. */ -extern void xalloc_die (void) ATTRIBUTE_NORETURN; +extern void xalloc_die (void) _GL_ATTRIBUTE_NORETURN; char *xmemdup0 (void const *p, size_t s); diff --git a/lib/xstrtol.h b/lib/xstrtol.h index f91d864..716a94f 100644 --- a/lib/xstrtol.h +++ b/lib/xstrtol.h @@ -52,9 +52,9 @@ _DECLARE_XSTRTOL (xstrtoull, unsigned long long int) #endif #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) #else -# define ATTRIBUTE_NORETURN /* empty */ +# define _GL_ATTRIBUTE_NORETURN /* empty */ #endif /* Report an error for an invalid integer in an option argument. @@ -74,6 +74,6 @@ _DECLARE_XSTRTOL (xstrtoull, unsigned long long int) void xstrtol_fatal (enum strtol_error, int, char, struct option const *, - char const *) ATTRIBUTE_NORETURN; + char const *) _GL_ATTRIBUTE_NORETURN; #endif /* not XSTRTOL_H_ */ diff --git a/tests/test-argmatch.c b/tests/test-argmatch.c index 57ec0d5..7392f57 100644 --- a/tests/test-argmatch.c +++ b/tests/test-argmatch.c @@ -30,12 +30,12 @@ thus must link with a definition of that function. Provide it here. */ #ifdef ARGMATCH_DIE_DECL # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # else -# define ATTRIBUTE_NORETURN /* empty */ +# define _GL_ATTRIBUTE_NORETURN /* empty */ # endif -ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN; +ARGMATCH_DIE_DECL _GL_ATTRIBUTE_NORETURN; ARGMATCH_DIE_DECL { exit (1); } #endif diff --git a/tests/test-exclude.c b/tests/test-exclude.c index bab4676..f0fb321 100644 --- a/tests/test-exclude.c +++ b/tests/test-exclude.c @@ -64,13 +64,13 @@ ARGMATCH_VERIFY (exclude_keywords, exclude_flags); thus must link with a definition of that function. Provide it here. */ #ifdef ARGMATCH_DIE_DECL # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) -# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) # else -# define ATTRIBUTE_NORETURN /* empty */ +# define _GL_ATTRIBUTE_NORETURN /* empty */ # endif #endif -ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN; +ARGMATCH_DIE_DECL _GL_ATTRIBUTE_NORETURN; ARGMATCH_DIE_DECL { exit (1); } #endif diff --git a/tests/test-ignore-value.c b/tests/test-ignore-value.c index a1c86e0..501f79c 100644 --- a/tests/test-ignore-value.c +++ b/tests/test-ignore-value.c @@ -23,20 +23,20 @@ #include <stdio.h> -#ifndef ATTRIBUTE_RETURN_CHECK +#ifndef _GL_ATTRIBUTE_RETURN_CHECK # if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1) -# define ATTRIBUTE_RETURN_CHECK +# define _GL_ATTRIBUTE_RETURN_CHECK # else -# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__)) +# define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__)) # endif #endif struct s { int i; }; -static char doChar (void) ATTRIBUTE_RETURN_CHECK; -static int doInt (void) ATTRIBUTE_RETURN_CHECK; -static off_t doOff (void) ATTRIBUTE_RETURN_CHECK; -static void *doPtr (void) ATTRIBUTE_RETURN_CHECK; -static struct s doStruct (void) ATTRIBUTE_RETURN_CHECK; +static char doChar (void) _GL_ATTRIBUTE_RETURN_CHECK; +static int doInt (void) _GL_ATTRIBUTE_RETURN_CHECK; +static off_t doOff (void) _GL_ATTRIBUTE_RETURN_CHECK; +static void *doPtr (void) _GL_ATTRIBUTE_RETURN_CHECK; +static struct s doStruct (void) _GL_ATTRIBUTE_RETURN_CHECK; static char doChar (void) -- 1.6.3.2