aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2015-07-24 18:13:41 +0000
committerWerner Koch <[email protected]>2015-07-24 18:13:41 +0000
commit4e790613f66efcfc62d73722d5f1730a37cb8324 (patch)
tree05288ab40502e6174682984738746f1dba999dbc
parentAllow building with --disable-threads. (diff)
downloadlibgpg-error-4e790613f66efcfc62d73722d5f1730a37cb8324.tar.gz
libgpg-error-4e790613f66efcfc62d73722d5f1730a37cb8324.zip
Add new public macros for GCC attributes.
* src/gpg-error.h.in (GPGRT_GCC_VERSION): New. (GPGRT_ATTR_NORETURN, GPGRT_ATTR_PRINTF, GPGRT_ATTR_NR_PRINTF): New. (GPGRT_ATTR_FORMAT_ARG, GPGRT_ATTR_SENTINEL): New. (GPGRT_ATTR_USED, GPGRT_ATTR_UNUSED, GPGRT_ATTR_DEPRECATED): New. (GPGRT_ATTR_PURE, GPGRT_ATTR_MALLOC): New. (GPGRT_HAVE_MACRO_FUNCTION, GPGRT_HAVE_PRAGMA_GCC_PUSH): New. (_GPGRT_GCC_A_PRINTF): Replace GPGRT_ATTR_PRINTF.
-rw-r--r--NEWS16
-rw-r--r--src/gpg-error.h.in114
-rw-r--r--src/gpgrt-int.h8
3 files changed, 116 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index ce29ff4..f24fd06 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,22 @@
Noteworthy changes in version 1.20 (unreleased) [C__/A__/R_]
-----------------------------------------------
+ * Interface changes relative to the 1.19 release:
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ GPGRT_GCC_VERSION NEW macro.
+ GPGRT_ATTR_NORETURN NEW macro.
+ GPGRT_ATTR_PRINTF NEW macro.
+ GPGRT_ATTR_NR_PRINTF NEW macro.
+ GPGRT_ATTR_FORMAT_ARG NEW macro.
+ GPGRT_ATTR_SENTINEL NEW macro.
+ GPGRT_ATTR_USED NEW macro.
+ GPGRT_ATTR_UNUSED NEW macro.
+ GPGRT_ATTR_DEPRECATED NEW macro.
+ GPGRT_ATTR_PURE NEW macro.
+ GPGRT_ATTR_MALLOC NEW macro.
+ GPGRT_HAVE_MACRO_FUNCTION NEW macro.
+ GPGRT_HAVE_PRAGMA_GCC_PUSH NEW macro.
+
Noteworthy changes in version 1.19 (2015-04-10) [C15/A15/R0]
-----------------------------------------------
diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in
index ff1162e..e85fbe5 100644
--- a/src/gpg-error.h.in
+++ b/src/gpg-error.h.in
@@ -147,19 +147,97 @@ typedef unsigned int gpg_error_t;
# define _GPG_ERR_CONSTRUCTOR
#endif
+#define GPGRT_GCC_VERSION _GCC_ERR_GCC_VERSION
+
+#if _GPG_ERR_GCC_VERSION >= 29200
+# define _GPGRT__RESTRICT __restrict__
+#else
+# define _GPGRT__RESTRICT
+#endif
+
+/* The noreturn attribute. */
+#if _GPG_ERR_GCC_VERSION >= 20500
+# define GPGRT_ATTR_NORETURN __attribute__ ((noreturn))
+#else
+# define GPGRT_ATTR_NORETURN
+#endif
+
+/* The printf attributes. */
#if _GPG_ERR_GCC_VERSION >= 40400
-# define _GPGRT_GCC_A_PRINTF(f, a) __attribute__ ((format(__gnu_printf__,f,a)))
+# define GPGRT_ATTR_PRINTF(f, a) \
+ __attribute__ ((format(__gnu_printf__,f,a)))
+# define GPGRT_ATTR_NR_PRINTF(f, a) \
+ __attribute__ ((noreturn, format(__gnu_printf__,f,a)))
#elif _GPG_ERR_GCC_VERSION >= 20500
-# define _GPGRT_GCC_A_PRINTF(f, a) __attribute__ ((format(printf,f,a)))
+# define GPGRT_ATTR_PRINTF(f, a) \
+ __attribute__ ((format(printf,f,a)))
+# define GPGRT_ATTR_NR_PRINTF(f, a) \
+ __attribute__ ((noreturn, format(printf,f,a)))
+#else
+# define GPGRT_ATTR_PRINTF(f, a)
+# define GPGRT_ATTR_NR_PRINTF(f, a)
+#endif
+#if _GPG_ERR_GCC_VERSION >= 20800
+# define GPGRT_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a)))
#else
-# define _GPGRT_GCC_A_PRINTF(f, a)
+# define GPGRT_ATTR_FORMAT_ARG(a)
#endif
-#if _GPG_ERR_GCC_VERSION >= 29200
-# define _GPGRT__RESTRICT __restrict__
+/* The sentinel attribute. */
+#if _GPG_ERR_GCC_VERSION >= 40000
+# define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a)))
#else
-# define _GPGRT__RESTRICT
+# define GPGRT_ATTR_SENTINEL(a)
+#endif
+
+/* The used and unused attributes.
+ I am not sure since when the unused attribute is really supported.
+ In any case it it only needed for gcc versions which print a
+ warning. Thus let us require gcc >= 3.5. */
+#if _GPG_ERR_GCC_VERSION >= 40000
+# define GPGRT_ATTR_USED __attribute__ ((used))
+#else
+# define GPGRT_ATTR_USED
#endif
+#if _GPG_ERR_GCC_VERSION >= 30500
+# define GPGRT_ATTR_UNUSED __attribute__ ((unused))
+#else
+# define GPGRT_ATTR_UNUSED
+#endif
+
+/* The deprecated attribute. */
+#if _GPG_ERR_GCC_VERSION >= 30100
+# define GPGRT_ATTR_DEPRECATED __attribute__ ((__deprecated__))
+#else
+# define GPGRT_ATTR_DEPRECATED
+#endif
+
+/* The pure attribute. */
+#if _GPG_ERR_GCC_VERSION >= 29600
+# define GPGRT_ATTR_PURE __attribute__ ((__pure__))
+#else
+# define GPGRT_ATTR_PURE
+#endif
+
+/* The malloc attribute. */
+#if _GPG_ERR_GCC_VERSION >= 30200
+# define GPGRT_ATTR_MALLOC __attribute__ ((__malloc__))
+#else
+# define GPGRT_ATTR_MALLOC
+#endif
+
+/* A macro defined if a GCC style __FUNCTION__ macro is available. */
+#undef GPGRT_HAVE_MACRO_FUNCTION
+#if _GPG_ERR_GCC_VERSION >= 20500
+# define GPGRT_HAVE_MACRO_FUNCTION 1
+#endif
+
+/* A macro defined if the pragma GCC push_options is available. */
+#undef GPGRT_HAVE_PRAGMA_GCC_PUSH
+#if _GPG_ERR_GCC_VERSION >= 40400
+# define GPGRT_HAVE_PRAGMA_GCC_PUSH 1
+#endif
+
@@ -577,22 +655,22 @@ void gpgrt_free (void *a);
int gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(2,3);
+ GPGRT_ATTR_PRINTF(2,3);
int gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(2,3);
+ GPGRT_ATTR_PRINTF(2,3);
int gpgrt_printf (const char *_GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(1,2);
+ GPGRT_ATTR_PRINTF(1,2);
int gpgrt_printf_unlocked (const char *_GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(1,2);
+ GPGRT_ATTR_PRINTF(1,2);
int gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, va_list ap)
- _GPGRT_GCC_A_PRINTF(2,0);
+ GPGRT_ATTR_PRINTF(2,0);
int gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, va_list ap)
- _GPGRT_GCC_A_PRINTF(2,0);
+ GPGRT_ATTR_PRINTF(2,0);
int gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
char *_GPGRT__RESTRICT buf, int mode, size_t size);
@@ -611,20 +689,20 @@ void gpgrt_fname_set (gpgrt_stream_t stream, const char *fname);
const char *gpgrt_fname_get (gpgrt_stream_t stream);
int gpgrt_asprintf (char **r_buf, const char * _GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(2,3);
+ GPGRT_ATTR_PRINTF(2,3);
int gpgrt_vasprintf (char **r_buf, const char * _GPGRT__RESTRICT format,
va_list ap)
- _GPGRT_GCC_A_PRINTF(2,0);
+ GPGRT_ATTR_PRINTF(2,0);
char *gpgrt_bsprintf (const char * _GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(1,2);
+ GPGRT_ATTR_PRINTF(1,2);
char *gpgrt_vbsprintf (const char * _GPGRT__RESTRICT format, va_list ap)
- _GPGRT_GCC_A_PRINTF(1,0);
+ GPGRT_ATTR_PRINTF(1,0);
int gpgrt_snprintf (char *buf, size_t bufsize,
const char * _GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(3,4);
+ GPGRT_ATTR_PRINTF(3,4);
int gpgrt_vsnprintf (char *buf,size_t bufsize,
const char * _GPGRT__RESTRICT format, va_list arg_ptr)
- _GPGRT_GCC_A_PRINTF(3,0);
+ GPGRT_ATTR_PRINTF(3,0);
#ifdef GPGRT_ENABLE_ES_MACROS
diff --git a/src/gpgrt-int.h b/src/gpgrt-int.h
index bc2db8b..34e5d72 100644
--- a/src/gpgrt-int.h
+++ b/src/gpgrt-int.h
@@ -173,17 +173,17 @@ gpgrt_ssize_t _gpgrt_read_line (gpgrt_stream_t stream,
int _gpgrt_fprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(2,3);
+ GPGRT_ATTR_PRINTF(2,3);
int _gpgrt_fprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, ...)
- _GPGRT_GCC_A_PRINTF(2,3);
+ GPGRT_ATTR_PRINTF(2,3);
int _gpgrt_vfprintf (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, va_list ap)
- _GPGRT_GCC_A_PRINTF(2,0);
+ GPGRT_ATTR_PRINTF(2,0);
int _gpgrt_vfprintf_unlocked (gpgrt_stream_t _GPGRT__RESTRICT stream,
const char *_GPGRT__RESTRICT format, va_list ap)
- _GPGRT_GCC_A_PRINTF(2,0);
+ GPGRT_ATTR_PRINTF(2,0);
int _gpgrt_setvbuf (gpgrt_stream_t _GPGRT__RESTRICT stream,
char *_GPGRT__RESTRICT buf, int mode, size_t size);