bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] stdlib: support non-GCC __attribute__


From: Bruno Haible
Subject: Re: [PATCH] stdlib: support non-GCC __attribute__
Date: Sun, 13 Feb 2011 12:34:01 +0100
User-agent: KMail/1.9.9

> I'm doing the same for stdio.in.h and string.in.h.

Actually, it seems it could be useful for applications to override gnulib's
definition of _GL_ATTRIBUTE_NORETURN and _GL_ATTRIBUTE_FORMAT. For example
in order to include support for other compilers, or for other reasons that
I'm not aware of now.

Here's a proposed patch:


2011-02-13  Bruno Haible  <address@hidden>

        Allow the application to provide its own attribute related macros.
        * lib/stdio.in.h (_GL_ATTRIBUTE_FORMAT): Don't define if already
        defined.
        * lib/stdlib.in.h (_GL_ATTRIBUTE_NORETURN): Likewise.
        * lib/string.in.h (_GL_ATTRIBUTE_PURE): Likewise.

--- lib/stdio.in.h.orig Sun Feb 13 12:29:40 2011
+++ lib/stdio.in.h      Sun Feb 13 12:29:00 2011
@@ -62,10 +62,12 @@
    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 _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
-#else
-# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+#ifndef _GL_ATTRIBUTE_FORMAT
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+#  define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+# else
+#  define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
+# endif
 #endif
 #define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
   _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
--- lib/stdlib.in.h.orig        Sun Feb 13 12:29:40 2011
+++ lib/stdlib.in.h     Sun Feb 13 12:28:18 2011
@@ -88,10 +88,12 @@
 # include <unistd.h>
 #endif
 
-#if 3 <= __GNUC__ || __GNUC__ == 2 && 8 <= __GNUC_MINOR__
-# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-#else
-# define _GL_ATTRIBUTE_NORETURN
+#ifndef _GL_ATTRIBUTE_NORETURN
+# if 3 <= __GNUC__ || __GNUC__ == 2 && 8 <= __GNUC_MINOR__
+#  define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# else
+#  define _GL_ATTRIBUTE_NORETURN
+# endif
 #endif
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
--- lib/string.in.h.orig        Sun Feb 13 12:29:40 2011
+++ lib/string.in.h     Sun Feb 13 12:28:33 2011
@@ -39,10 +39,12 @@
 
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The attribute __pure__ was added in gcc 2.96.  */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
-#else
-# define _GL_ATTRIBUTE_PURE /* empty */
+#ifndef _GL_ATTRIBUTE_PURE
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+#  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>.  */


-- 
In memoriam Alexander Samoylovich 
<http://en.wikipedia.org/wiki/Alexander_Samoylovich>



reply via email to

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