]> Savannah Git Hosting - gnulib.git/commitdiff
Make generated .in.h files as standalone as possible.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Aug 2021 21:54:40 +0000 (23:54 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 22 Aug 2021 21:54:40 +0000 (23:54 +0200)
Reported by Jan Engelhardt <jengelh@inai.de>.

* 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.

13 files changed:
ChangeLog
lib/dirent.in.h
lib/math.in.h
lib/pthread.in.h
lib/se-context.in.h
lib/se-label.in.h
lib/se-selinux.in.h
lib/stdio.in.h
lib/stdlib.in.h
lib/string.in.h
lib/textstyle.in.h
lib/threads.in.h
lib/uchar.in.h

index 8a31810301e16c7a974d870acaab391e68419bc0..bd235e7e98ed2de6eaa90d94aaf48a8b03a2cdd7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2021-08-22  Bruno Haible  <bruno@clisp.org>
+
+       Make generated .in.h files as standalone as possible.
+       Reported by Jan Engelhardt <jengelh@inai.de>.
+       * 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  <bruno@clisp.org>
 
        gnulib-common.m4: Clarify logic behind _GL_UNUSED_LABEL.
index 5775edf09437c8a199c854daf9a0873b8896db55..4deb0cb466af190480c4197c1b8bd6258891f366 100644 (file)
@@ -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
index 6a055fbf557098e3cb4e988d13898f99322455f1..c87cc12fc77af24f1b961b79f7f684bddb8425bc 100644 (file)
@@ -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.  */
index c4cd36c126b981c9cd8ebd82dc1d52d1ac631bb4..65693d5d10f20f94de1abf233f66f346e4eca159 100644 (file)
 #include <sys/types.h>
 #include <time.h>
 
+/* 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.  */
index d4ed6a4c1aca8029f96433aa6e684bef2b579718..a6c178ad683a82e1895141e391df9607b3d1ee75 100644 (file)
@@ -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)
index 2bf1eb88c2b5c58479d08c5e258bb29d8bb8f7f7..c3d19816a0807c974cb6dbe153dbd5b3508fdeb1 100644 (file)
@@ -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;
index 85dae11810f6428389cc7a7729b8d24764ad1250..171870d29ca8f681c6eb007e16c47e09847b7aa7 100644 (file)
@@ -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;
index f1bf817322d4e01ec289df0e60e1fe782685f4f2..0ca2c8e10c51c1d702fefc50b04e82d7b5d1cf85 100644 (file)
    May also define off_t to a 64-bit type on native Windows.  */
 #include <sys/types.h>
 
+/* Solaris 10 and NetBSD 7.0 declare renameat in <unistd.h>, not in <stdio.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
+    && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
+/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
+    && ! defined __GLIBC__
+# include <sys/stat.h>
+#endif
+
+/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  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 <stdlib.h>
+#endif
+
+/* MSVC declares 'remove' in <io.h>, not in <stdio.h>.  We must include
+   it before we  #define remove rpl_remove.  */
+/* MSVC declares 'rename' in <io.h>, not in <stdio.h>.  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 <io.h>
+#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.
 #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 <unistd.h>, not in <stdio.h>.  */
-/* But in any case avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && (defined __sun || defined __NetBSD__) \
-    && ! defined __GLIBC__
-# include <unistd.h>
-#endif
-
-/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>.  */
-/* But in any case avoid namespace pollution on glibc systems.  */
-#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
-    && ! defined __GLIBC__
-# include <sys/stat.h>
-#endif
-
-/* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  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 <stdlib.h>
-#endif
-
-/* MSVC declares 'remove' in <io.h>, not in <stdio.h>.  We must include
-   it before we  #define remove rpl_remove.  */
-/* MSVC declares 'rename' in <io.h>, not in <stdio.h>.  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 <io.h>
-#endif
-
-
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
index d86a880710fe7a7ba6551b68de3bb11f93e10149..d0ea07f8bcdaa9dce58e42ae8d44ed733eed786f 100644 (file)
@@ -99,6 +99,35 @@ struct random_data
 # include <unistd.h>
 #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 <stdlib.h>.  */
+/* 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
index b043c752274f9e780f3a37914b9959a584e0e3e3..fa2e40c257c401c65bd3b4f609a43209ab156331 100644 (file)
 # include <wchar.h>
 #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 <unistd.h>, not in <string.h>.  */
 /* But in any case avoid namespace pollution on glibc systems.  */
 #if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
 # include <strings.h>
 #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.  */
index a160cda483f0547a113faf56b13a1cd03c2cdf91..2b823f1d7fc1ce318e7666bc25ca73af9dcea6a6 100644 (file)
 # include <termios.h>
 #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)
 {
 }
 
index 4e4be3e599efa028b77085c981b327378164ad3a..b1706637f296666850a386196136ace73d0442dc 100644 (file)
 
 #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.  */
index a03231e17e467372bae45de657d063fc2d2cb821..29086defb00f48d43d2955c1aad2a6295a58de0c 100644 (file)
 /* Get mbstate_t, size_t.  */
 #include <wchar.h>
 
+/* 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.  */