From 354f27fea9bd4ecb53980de6bd374434a204afc5 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Aug 2021 23:54:40 +0200 Subject: [PATCH] Make generated .in.h files as standalone as possible. Reported by Jan Engelhardt . * lib/stdlib.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE, _GL_ATTRIBUTE_MALLOC): Add fallback definitions. * lib/dirent.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC): Add fallback definitions. * lib/stdio.in.h (_GL_ATTRIBUTE_DEALLOC): Add fallback definition. * lib/math.in.h (_GL_ATTRIBUTE_CONST): Add fallback definition. * lib/pthread.in.h (_GL_ATTRIBUTE_PURE): Add fallback definition. * lib/threads.in.h (_GL_ATTRIBUTE_PURE): Likewise. * lib/uchar.in.h (_GL_ATTRIBUTE_PURE): Likewise. * lib/string.in.h (_GL_ATTRIBUTE_PURE): Move definition, for consistency with the other *.in.h files. * lib/se-context.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Add fallback definition. * lib/se-label.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Likewise. * lib/se-selinux.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Likewise. * lib/textstyle.in.h: Use _GL_ATTRIBUTE_MAYBE_UNUSED instead of _GL_UNUSED. (_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_MAYBE_UNUSED): Add fallback definitions. --- ChangeLog | 24 +++++++++ lib/dirent.in.h | 22 +++++++++ lib/math.in.h | 10 ++++ lib/pthread.in.h | 10 ++++ lib/se-context.in.h | 13 +++++ lib/se-label.in.h | 13 +++++ lib/se-selinux.in.h | 13 +++++ lib/stdio.in.h | 81 +++++++++++++++++------------- lib/stdlib.in.h | 29 +++++++++++ lib/string.in.h | 20 ++++---- lib/textstyle.in.h | 118 +++++++++++++++++++++++++++----------------- lib/threads.in.h | 10 ++++ lib/uchar.in.h | 10 ++++ 13 files changed, 282 insertions(+), 91 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a31810301..bd235e7e98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2021-08-22 Bruno Haible + + Make generated .in.h files as standalone as possible. + Reported by Jan Engelhardt . + * lib/stdlib.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_DEALLOC_FREE, + _GL_ATTRIBUTE_MALLOC): Add fallback definitions. + * lib/dirent.in.h (_GL_ATTRIBUTE_DEALLOC, _GL_ATTRIBUTE_MALLOC): Add + fallback definitions. + * lib/stdio.in.h (_GL_ATTRIBUTE_DEALLOC): Add fallback definition. + * lib/math.in.h (_GL_ATTRIBUTE_CONST): Add fallback definition. + * lib/pthread.in.h (_GL_ATTRIBUTE_PURE): Add fallback definition. + * lib/threads.in.h (_GL_ATTRIBUTE_PURE): Likewise. + * lib/uchar.in.h (_GL_ATTRIBUTE_PURE): Likewise. + * lib/string.in.h (_GL_ATTRIBUTE_PURE): Move definition, for consistency + with the other *.in.h files. + * lib/se-context.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Add fallback + definition. + * lib/se-label.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Likewise. + * lib/se-selinux.in.h (_GL_ATTRIBUTE_MAYBE_UNUSED): Likewise. + * lib/textstyle.in.h: Use _GL_ATTRIBUTE_MAYBE_UNUSED instead of + _GL_UNUSED. + (_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, _GL_ATTRIBUTE_MAYBE_UNUSED): Add + fallback definitions. + 2021-08-22 Bruno Haible gnulib-common.m4: Clarify logic behind _GL_UNUSED_LABEL. diff --git a/lib/dirent.in.h b/lib/dirent.in.h index 5775edf094..4deb0cb466 100644 --- a/lib/dirent.in.h +++ b/lib/dirent.in.h @@ -55,6 +55,28 @@ typedef struct gl_directory DIR; # endif #endif +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if __GNUC__ >= 11 +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + /* The __attribute__ feature is available in gcc versions 2.5 and later. The attribute __pure__ was added in gcc 2.96. */ #ifndef _GL_ATTRIBUTE_PURE diff --git a/lib/math.in.h b/lib/math.in.h index 6a055fbf55..c87cc12fc7 100644 --- a/lib/math.in.h +++ b/lib/math.in.h @@ -56,6 +56,16 @@ _GL_INLINE_HEADER_BEGIN # define _GL_MATH_INLINE _GL_INLINE #endif +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __const__ was added in gcc 2.95. */ +#ifndef _GL_ATTRIBUTE_CONST +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) || defined __clang__ +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) +# else +# define _GL_ATTRIBUTE_CONST /* empty */ +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ diff --git a/lib/pthread.in.h b/lib/pthread.in.h index c4cd36c126..65693d5d10 100644 --- a/lib/pthread.in.h +++ b/lib/pthread.in.h @@ -69,6 +69,16 @@ #include #include +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _Noreturn is copied here. */ diff --git a/lib/se-context.in.h b/lib/se-context.in.h index d4ed6a4c1a..a6c178ad68 100644 --- a/lib/se-context.in.h +++ b/lib/se-context.in.h @@ -29,6 +29,19 @@ _GL_INLINE_HEADER_BEGIN # define SE_CONTEXT_INLINE _GL_INLINE #endif +/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if + the entity is not used. The compiler should not warn if the entity is not + used. */ +#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# if 0 /* no GCC or clang version supports this yet */ +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# elif defined __GNUC__ || defined __clang__ +# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +# else +# define _GL_ATTRIBUTE_MAYBE_UNUSED +# endif +#endif + typedef int context_t; SE_CONTEXT_INLINE context_t context_new (_GL_ATTRIBUTE_MAYBE_UNUSED char const *s) diff --git a/lib/se-label.in.h b/lib/se-label.in.h index 2bf1eb88c2..c3d19816a0 100644 --- a/lib/se-label.in.h +++ b/lib/se-label.in.h @@ -31,6 +31,19 @@ _GL_INLINE_HEADER_BEGIN # define SE_LABEL_INLINE _GL_INLINE #endif +/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if + the entity is not used. The compiler should not warn if the entity is not + used. */ +#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# if 0 /* no GCC or clang version supports this yet */ +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# elif defined __GNUC__ || defined __clang__ +# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +# else +# define _GL_ATTRIBUTE_MAYBE_UNUSED +# endif +#endif + #define SELABEL_CTX_FILE 0 struct selabel_handle; diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h index 85dae11810..171870d29c 100644 --- a/lib/se-selinux.in.h +++ b/lib/se-selinux.in.h @@ -38,6 +38,19 @@ _GL_INLINE_HEADER_BEGIN # define SE_SELINUX_INLINE _GL_INLINE # endif +/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if + the entity is not used. The compiler should not warn if the entity is not + used. */ +# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# if 0 /* no GCC or clang version supports this yet */ +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# elif defined __GNUC__ || defined __clang__ +# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +# else +# define _GL_ATTRIBUTE_MAYBE_UNUSED +# endif +# endif + # if !GNULIB_defined_security_types typedef unsigned short security_class_t; diff --git a/lib/stdio.in.h b/lib/stdio.in.h index f1bf817322..0ca2c8e10c 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -56,6 +56,52 @@ May also define off_t to a 64-bit type on native Windows. */ #include +/* Solaris 10 and NetBSD 7.0 declare renameat in , not in . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \ + && ! defined __GLIBC__ +# include +#endif + +/* Android 4.3 declares renameat in , not in . */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \ + && ! defined __GLIBC__ +# include +#endif + +/* MSVC declares 'perror' in , not in . We must include + it before we #define perror rpl_perror. */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__) \ + && ! defined __GLIBC__ +# include +#endif + +/* MSVC declares 'remove' in , not in . We must include + it before we #define remove rpl_remove. */ +/* MSVC declares 'rename' in , not in . We must include + it before we #define rename rpl_rename. */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \ + && (defined _WIN32 && ! defined __CYGWIN__) \ + && ! defined __GLIBC__ +# include +#endif + + +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if __GNUC__ >= 11 +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif + /* 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. @@ -127,41 +173,6 @@ #define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \ _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument)) -/* Solaris 10 and NetBSD 7.0 declare renameat in , not in . */ -/* But in any case avoid namespace pollution on glibc systems. */ -#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \ - && ! defined __GLIBC__ -# include -#endif - -/* Android 4.3 declares renameat in , not in . */ -/* But in any case avoid namespace pollution on glibc systems. */ -#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \ - && ! defined __GLIBC__ -# include -#endif - -/* MSVC declares 'perror' in , not in . We must include - it before we #define perror rpl_perror. */ -/* But in any case avoid namespace pollution on glibc systems. */ -#if (@GNULIB_PERROR@ || defined GNULIB_POSIXCHECK) \ - && (defined _WIN32 && ! defined __CYGWIN__) \ - && ! defined __GLIBC__ -# include -#endif - -/* MSVC declares 'remove' in , not in . We must include - it before we #define remove rpl_remove. */ -/* MSVC declares 'rename' in , not in . We must include - it before we #define rename rpl_rename. */ -/* But in any case avoid namespace pollution on glibc systems. */ -#if (@GNULIB_REMOVE@ || @GNULIB_RENAME@ || defined GNULIB_POSIXCHECK) \ - && (defined _WIN32 && ! defined __CYGWIN__) \ - && ! defined __GLIBC__ -# include -#endif - - /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index d86a880710..d0ea07f8bc 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -99,6 +99,35 @@ struct random_data # include #endif +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if __GNUC__ >= 11 +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif + +/* _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after including . */ +/* Applies to: functions. Cannot be used on inline functions. */ +#ifndef _GL_ATTRIBUTE_DEALLOC_FREE +# define _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_DEALLOC (free, 1) +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 || defined __clang__ +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + /* The __attribute__ feature is available in gcc versions 2.5 and later. The attribute __pure__ was added in gcc 2.96. */ #ifndef _GL_ATTRIBUTE_PURE diff --git a/lib/string.in.h b/lib/string.in.h index b043c75227..fa2e40c257 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -55,16 +55,6 @@ # include #endif -/* The __attribute__ feature is available in gcc versions 2.5 and later. - The attribute __pure__ was added in gcc 2.96. */ -#ifndef _GL_ATTRIBUTE_PURE -# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ -# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) -# else -# define _GL_ATTRIBUTE_PURE /* empty */ -# endif -#endif - /* NetBSD 5.0 declares strsignal in , not in . */ /* But in any case avoid namespace pollution on glibc systems. */ #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ @@ -80,6 +70,16 @@ # include #endif +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _GL_ARG_NONNULL is copied here. */ diff --git a/lib/textstyle.in.h b/lib/textstyle.in.h index a160cda483..2b823f1d7f 100644 --- a/lib/textstyle.in.h +++ b/lib/textstyle.in.h @@ -42,6 +42,32 @@ # include #endif +/* An __attribute__ __format__ specifier for a function that takes a format + string and arguments, where the format string directives are the ones + standardized by ISO C99 and POSIX. + _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD */ +/* __gnu_printf__ is supported in GCC >= 4.4. */ +#ifndef _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) +# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __gnu_printf__ +# else +# define _GL_ATTRIBUTE_SPEC_PRINTF_STANDARD __printf__ +# endif +#endif + +/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if + the entity is not used. The compiler should not warn if the entity is not + used. */ +#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# if 0 /* no GCC or clang version supports this yet */ +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# elif defined __GNUC__ || defined __clang__ +# define _GL_ATTRIBUTE_MAYBE_UNUSED __attribute__ ((__unused__)) +# else +# define _GL_ATTRIBUTE_MAYBE_UNUSED +# endif +#endif + /* ----------------------------- From ostream.h ----------------------------- */ /* Describes the scope of a flush operation. */ @@ -167,38 +193,38 @@ typedef ostream_t styled_ostream_t; #define styled_ostream_free ostream_free static inline void -styled_ostream_begin_use_class (_GL_UNUSED styled_ostream_t stream, - _GL_UNUSED const char *classname) +styled_ostream_begin_use_class (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname) { } static inline void -styled_ostream_end_use_class (_GL_UNUSED styled_ostream_t stream, - _GL_UNUSED const char *classname) +styled_ostream_end_use_class (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *classname) { } static inline const char * -styled_ostream_get_hyperlink_ref (_GL_UNUSED styled_ostream_t stream) +styled_ostream_get_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream) { return NULL; } static inline const char * -styled_ostream_get_hyperlink_id (_GL_UNUSED styled_ostream_t stream) +styled_ostream_get_hyperlink_id (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream) { return NULL; } static inline void -styled_ostream_set_hyperlink (_GL_UNUSED styled_ostream_t stream, - _GL_UNUSED const char *ref, - _GL_UNUSED const char *id) +styled_ostream_set_hyperlink (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *ref, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *id) { } static inline void -styled_ostream_flush_to_current_style (_GL_UNUSED styled_ostream_t stream) +styled_ostream_flush_to_current_style (_GL_ATTRIBUTE_MAYBE_UNUSED styled_ostream_t stream) { } @@ -225,8 +251,8 @@ typedef ostream_t fd_ostream_t; #define fd_ostream_free ostream_free static inline fd_ostream_t -fd_ostream_create (int fd, _GL_UNUSED const char *filename, - _GL_UNUSED bool buffered) +fd_ostream_create (int fd, _GL_ATTRIBUTE_MAYBE_UNUSED const char *filename, + _GL_ATTRIBUTE_MAYBE_UNUSED bool buffered) { if (fd == 1) return stdout; @@ -272,81 +298,81 @@ typedef ostream_t term_ostream_t; #define term_ostream_free ostream_free static inline term_color_t -term_ostream_get_color (_GL_UNUSED term_ostream_t stream) +term_ostream_get_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) { return COLOR_DEFAULT; } static inline void -term_ostream_set_color (_GL_UNUSED term_ostream_t stream, - _GL_UNUSED term_color_t color) +term_ostream_set_color (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED term_color_t color) { } static inline term_color_t -term_ostream_get_bgcolor (_GL_UNUSED term_ostream_t stream) +term_ostream_get_bgcolor (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) { return COLOR_DEFAULT; } static inline void -term_ostream_set_bgcolor (_GL_UNUSED term_ostream_t stream, - _GL_UNUSED term_color_t color) +term_ostream_set_bgcolor (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED term_color_t color) { } static inline term_weight_t -term_ostream_get_weight (_GL_UNUSED term_ostream_t stream) +term_ostream_get_weight (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) { return WEIGHT_DEFAULT; } static inline void -term_ostream_set_weight (_GL_UNUSED term_ostream_t stream, - _GL_UNUSED term_weight_t weight) +term_ostream_set_weight (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED term_weight_t weight) { } static inline term_posture_t -term_ostream_get_posture (_GL_UNUSED term_ostream_t stream) +term_ostream_get_posture (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) { return POSTURE_DEFAULT; } static inline void -term_ostream_set_posture (_GL_UNUSED term_ostream_t stream, - _GL_UNUSED term_posture_t posture) +term_ostream_set_posture (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED term_posture_t posture) { } static inline term_underline_t -term_ostream_get_underline (_GL_UNUSED term_ostream_t stream) +term_ostream_get_underline (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) { return UNDERLINE_DEFAULT; } static inline void -term_ostream_set_underline (_GL_UNUSED term_ostream_t stream, - _GL_UNUSED term_underline_t underline) +term_ostream_set_underline (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED term_underline_t underline) { } static inline const char * -term_ostream_get_hyperlink_ref (_GL_UNUSED term_ostream_t stream) +term_ostream_get_hyperlink_ref (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) { return NULL; } static inline const char * -term_ostream_get_hyperlink_id (_GL_UNUSED term_ostream_t stream) +term_ostream_get_hyperlink_id (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream) { return NULL; } static inline void -term_ostream_set_hyperlink (_GL_UNUSED term_ostream_t stream, - _GL_UNUSED const char *ref, - _GL_UNUSED const char *id) +term_ostream_set_hyperlink (_GL_ATTRIBUTE_MAYBE_UNUSED term_ostream_t stream, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *ref, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *id) { } @@ -374,7 +400,7 @@ typedef enum static inline term_ostream_t term_ostream_create (int fd, const char *filename, - _GL_UNUSED ttyctl_t tty_control) + _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control) { return fd_ostream_create (fd, filename, true); } @@ -395,8 +421,8 @@ typedef styled_ostream_t term_styled_ostream_t; static inline term_styled_ostream_t term_styled_ostream_create (int fd, const char *filename, - _GL_UNUSED ttyctl_t tty_control, - _GL_UNUSED const char *css_filename) + _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename) { return fd_ostream_create (fd, filename, true); } @@ -406,8 +432,8 @@ term_styled_ostream_create (int fd, const char *filename, typedef styled_ostream_t html_styled_ostream_t; static inline html_styled_ostream_t -html_styled_ostream_create (_GL_UNUSED ostream_t destination, - _GL_UNUSED const char *css_filename) +html_styled_ostream_create (_GL_ATTRIBUTE_MAYBE_UNUSED ostream_t destination, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename) { abort (); return NULL; @@ -423,13 +449,13 @@ enum color_option { color_no, color_tty, color_yes, color_html }; #define style_file_name NULL static inline bool -handle_color_option (_GL_UNUSED const char *option) +handle_color_option (_GL_ATTRIBUTE_MAYBE_UNUSED const char *option) { return false; } static inline void -handle_style_option (_GL_UNUSED const char *option) +handle_style_option (_GL_ATTRIBUTE_MAYBE_UNUSED const char *option) { } @@ -440,10 +466,10 @@ print_color_test (void) } static inline void -style_file_prepare (_GL_UNUSED const char *style_file_envvar, - _GL_UNUSED const char *stylesdir_envvar, - _GL_UNUSED const char *stylesdir_after_install, - _GL_UNUSED const char *default_style_file) +style_file_prepare (_GL_ATTRIBUTE_MAYBE_UNUSED const char *style_file_envvar, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *stylesdir_envvar, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *stylesdir_after_install, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *default_style_file) { } @@ -451,14 +477,14 @@ style_file_prepare (_GL_UNUSED const char *style_file_envvar, static inline styled_ostream_t styled_ostream_create (int fd, const char *filename, - _GL_UNUSED ttyctl_t tty_control, - _GL_UNUSED const char *css_filename) + _GL_ATTRIBUTE_MAYBE_UNUSED ttyctl_t tty_control, + _GL_ATTRIBUTE_MAYBE_UNUSED const char *css_filename) { return fd_ostream_create (fd, filename, true); } static inline void -libtextstyle_set_failure_exit_code (_GL_UNUSED int exit_code) +libtextstyle_set_failure_exit_code (_GL_ATTRIBUTE_MAYBE_UNUSED int exit_code) { } diff --git a/lib/threads.in.h b/lib/threads.in.h index 4e4be3e599..b1706637f2 100644 --- a/lib/threads.in.h +++ b/lib/threads.in.h @@ -49,6 +49,16 @@ #endif +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ /* The definition of _Noreturn is copied here. */ diff --git a/lib/uchar.in.h b/lib/uchar.in.h index a03231e17e..29086defb0 100644 --- a/lib/uchar.in.h +++ b/lib/uchar.in.h @@ -37,6 +37,16 @@ /* Get mbstate_t, size_t. */ #include +/* The __attribute__ feature is available in gcc versions 2.5 and later. + The attribute __pure__ was added in gcc 2.96. */ +#ifndef _GL_ATTRIBUTE_PURE +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__ +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE /* empty */ +# endif +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ -- 2.39.5