diff options
author | Werner Koch <[email protected]> | 2015-07-26 10:50:16 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2015-07-26 10:50:24 +0000 |
commit | d382242fb6789973ce8d246ec154a4a1468c24c0 (patch) | |
tree | 3809b220992ea4e49942a3dec3d7a2f5e96738f6 /common | |
parent | scd: support any curves defined by libgcrypt. (diff) | |
download | gnupg-d382242fb6789973ce8d246ec154a4a1468c24c0.tar.gz gnupg-d382242fb6789973ce8d246ec154a4a1468c24c0.zip |
Replace GNUPG_GCC_A_ macros by GPGRT_ATTR_ macros.
* common/util.h: Provide replacement for GPGRT_ATTR_ macros when using
libgpg-error < 1.20.
* common/mischelp.h: Ditto.
* common/types.h: Ditto.
--
Given that libgpg-error is a dependency of all GnuPG related libraries
it is better to define such macros at only one place instead of having
similar macros at a lot of places. For now we need repalcement
macros, though.
Diffstat (limited to 'common')
-rw-r--r-- | common/asshelp.h | 4 | ||||
-rw-r--r-- | common/audit.c | 6 | ||||
-rw-r--r-- | common/logging.h | 19 | ||||
-rw-r--r-- | common/membuf.h | 2 | ||||
-rw-r--r-- | common/mischelp.h | 41 | ||||
-rw-r--r-- | common/stringhelp.h | 12 | ||||
-rw-r--r-- | common/types.h | 14 | ||||
-rw-r--r-- | common/util.h | 44 |
8 files changed, 76 insertions, 66 deletions
diff --git a/common/asshelp.h b/common/asshelp.h index c685564a6..6a52172f5 100644 --- a/common/asshelp.h +++ b/common/asshelp.h @@ -81,11 +81,11 @@ start_new_dirmngr (assuan_context_t *r_ctx, gpg_error_t print_assuan_status (assuan_context_t ctx, const char *keyword, const char *format, - ...) GPGRT_GCC_A_PRINTF(3,4); + ...) GPGRT_ATTR_PRINTF(3,4); gpg_error_t vprint_assuan_status (assuan_context_t ctx, const char *keyword, const char *format, - va_list arg_ptr) GPGRT_GCC_A_PRINTF(3,0); + va_list arg_ptr) GPGRT_ATTR_PRINTF(3,0); #endif /*GNUPG_COMMON_ASSHELP_H*/ diff --git a/common/audit.c b/common/audit.c index 9ed5708de..198b8e633 100644 --- a/common/audit.c +++ b/common/audit.c @@ -72,11 +72,11 @@ struct audit_ctx_s static void writeout_para (audit_ctx_t ctx, - const char *format, ...) GPGRT_GCC_A_PRINTF(2,3); + const char *format, ...) GPGRT_ATTR_PRINTF(2,3); static void writeout_li (audit_ctx_t ctx, const char *oktext, - const char *format, ...) GPGRT_GCC_A_PRINTF(3,4); + const char *format, ...) GPGRT_ATTR_PRINTF(3,4); static void writeout_rem (audit_ctx_t ctx, - const char *format, ...) GPGRT_GCC_A_PRINTF(2,3); + const char *format, ...) GPGRT_ATTR_PRINTF(2,3); /* Add NAME to the list of help tags. NAME needs to be a const string diff --git a/common/logging.h b/common/logging.h index 0bd1a6c7f..dbfc8bae6 100644 --- a/common/logging.h +++ b/common/logging.h @@ -48,8 +48,9 @@ int log_test_fd (int fd); int log_get_fd(void); estream_t log_get_stream (void); -#ifdef GPGRT_GCC_M_FUNCTION - void bug_at( const char *file, int line, const char *func ) GPGRT_GCC_A_NR; +#ifdef GPGRT_HAVE_MACRO_FUNCTION + void bug_at (const char *file, int line, const char *func) + GPGRT_ATTR_NORETURN; # define BUG() bug_at( __FILE__ , __LINE__, __FUNCTION__ ) #else void bug_at( const char *file, int line ); @@ -74,17 +75,17 @@ enum jnlib_log_levels { GPGRT_LOG_BUG, GPGRT_LOG_DEBUG }; -void log_log (int level, const char *fmt, ...) GPGRT_GCC_A_PRINTF(2,3); +void log_log (int level, const char *fmt, ...) GPGRT_ATTR_PRINTF(2,3); void log_logv (int level, const char *fmt, va_list arg_ptr); void log_string (int level, const char *string); -void log_bug( const char *fmt, ... ) GPGRT_GCC_A_NR_PRINTF(1,2); -void log_fatal( const char *fmt, ... ) GPGRT_GCC_A_NR_PRINTF(1,2); -void log_error( const char *fmt, ... ) GPGRT_GCC_A_PRINTF(1,2); -void log_info( const char *fmt, ... ) GPGRT_GCC_A_PRINTF(1,2); -void log_debug( const char *fmt, ... ) GPGRT_GCC_A_PRINTF(1,2); -void log_printf( const char *fmt, ... ) GPGRT_GCC_A_PRINTF(1,2); +void log_bug (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); +void log_fatal (const char *fmt, ...) GPGRT_ATTR_NR_PRINTF(1,2); +void log_error (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); +void log_info (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); +void log_debug (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); +void log_printf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); void log_flush (void); /* Print a hexdump of BUFFER. With TEXT passes as NULL print just the diff --git a/common/membuf.h b/common/membuf.h index 32d4f90a2..eb7d5650a 100644 --- a/common/membuf.h +++ b/common/membuf.h @@ -55,7 +55,7 @@ void clear_membuf (membuf_t *mb, size_t amount); void put_membuf (membuf_t *mb, const void *buf, size_t len); void put_membuf_str (membuf_t *mb, const char *string); void put_membuf_printf (membuf_t *mb, const char *format, - ...) GPGRT_GCC_A_PRINTF(2,3); + ...) GPGRT_ATTR_PRINTF(2,3); void *get_membuf (membuf_t *mb, size_t *len); void *get_membuf_shrink (membuf_t *mb, size_t *len); const void *peek_membuf (membuf_t *mb, size_t *len); diff --git a/common/mischelp.h b/common/mischelp.h index ecbf38b5c..cd72a4a65 100644 --- a/common/mischelp.h +++ b/common/mischelp.h @@ -48,27 +48,32 @@ time_t timegm (struct tm *tm); #define DIMof(type,member) DIM(((type *)0)->member) -#undef GPGRT_GCC_HAVE_PUSH_PRAGMA -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) -# define GPGRT_GCC_M_FUNCTION 1 /* __FUNCTION__ macro is available. */ -# define GPGRT_GCC_A_NR __attribute__ ((noreturn)) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) -# define GPGRT_GCC_HAVE_PUSH_PRAGMA 1 -# define GPGRT_GCC_A_PRINTF( f, a ) \ - __attribute__ ((format (__gnu_printf__,f,a))) -# define GPGRT_GCC_A_NR_PRINTF( f, a ) \ - __attribute__ ((noreturn, format (__gnu_printf__,f,a))) +/* Replacements for macros not available with libgpg-error < 1.20. */ +#ifndef GPGRT_GCC_VERSION + +# undef GPGRT_HAVE_PRAGMA_GCC_PUSH +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) +# define GPGRT_HAVE_MACRO_FUNCTION 1 /* __FUNCTION__ macro is available. */ +# define GPGRT_ATTR_NORETURN __attribute__ ((noreturn)) +# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) +# define GPGRT_HAVE_PRAGMA_GCC_PUSH 1 +# 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))) +# else +# define GPGRT_ATTR_PRINTF(f, a) \ + __attribute__ ((format (printf,f,a))) +# define GPGRT_ATTR_NR_PRINTF(f, a) \ + __attribute__ ((noreturn, format (printf,f,a))) +# endif # else -# define GPGRT_GCC_A_PRINTF( f, a ) __attribute__ ((format (printf,f,a))) -# define GPGRT_GCC_A_NR_PRINTF( f, a ) \ - __attribute__ ((noreturn, format (printf,f,a))) +# define GPGRT_ATTR_NORETURN +# define GPGRT_ATTR_PRINTF( f, a ) +# define GPGRT_ATTR_NR_PRINTF( f, a ) # endif -#else -# define GPGRT_GCC_A_NR -# define GPGRT_GCC_A_PRINTF( f, a ) -# define GPGRT_GCC_A_NR_PRINTF( f, a ) -#endif +#endif /*Older libgpg-error. */ /* To avoid that a compiler optimizes certain memset calls away, these macros may be used instead. */ diff --git a/common/stringhelp.h b/common/stringhelp.h index ab16d169c..a84c81b3f 100644 --- a/common/stringhelp.h +++ b/common/stringhelp.h @@ -52,11 +52,11 @@ size_t length_sans_trailing_ws (const unsigned char *line, size_t len); char *make_basename(const char *filepath, const char *inputpath); char *make_dirname(const char *filepath); -char *make_filename( const char *first_part, ... ) GNUPG_GCC_A_SENTINEL(0); -char *make_filename_try (const char *first_part, ... ) GNUPG_GCC_A_SENTINEL(0); -char *make_absfilename (const char *first_part, ...) GNUPG_GCC_A_SENTINEL(0); +char *make_filename( const char *first_part, ... ) GPGRT_ATTR_SENTINEL(0); +char *make_filename_try (const char *first_part, ... ) GPGRT_ATTR_SENTINEL(0); +char *make_absfilename (const char *first_part, ...) GPGRT_ATTR_SENTINEL(0); char *make_absfilename_try (const char *first_part, - ...) GNUPG_GCC_A_SENTINEL(0); + ...) GPGRT_ATTR_SENTINEL(0); int compare_filenames( const char *a, const char *b ); int hextobyte (const char *s); @@ -139,9 +139,9 @@ char *try_percent_escape (const char *str, const char *extra); /* Concatenate the string S1 with all the following strings up to a NULL. Returns a malloced buffer with the new string or NULL on a malloc error or if too many arguments are given. */ -char *strconcat (const char *s1, ...) GNUPG_GCC_A_SENTINEL(0); +char *strconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0); /* Ditto, but die on error. */ -char *xstrconcat (const char *s1, ...) GNUPG_GCC_A_SENTINEL(0); +char *xstrconcat (const char *s1, ...) GPGRT_ATTR_SENTINEL(0); char **strsplit (char *string, char delim, char replacement, int *count); diff --git a/common/types.h b/common/types.h index 8d7730b2e..2bb817faf 100644 --- a/common/types.h +++ b/common/types.h @@ -114,13 +114,13 @@ #endif -/* Some GCC attributes. Note that we use also define some in - mischelp.h, but this header and types.h are not always included. - Should eventually be put into one file (e.g. nlib-common.h). */ -#if __GNUC__ >= 4 -# define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a))) -#else -# define GNUPG_GCC_A_SENTINEL(a) +/* Some GCC attributes. These are replacements for libgpg-error < 1.20. */ +#ifndef GPGRT_GCC_VERSION +# if __GNUC__ >= 4 +# define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a))) +# else +# define GPGRT_ATTR_SENTINEL(a) +# endif #endif #endif /*GNUPG_COMMON_TYPES_H*/ diff --git a/common/util.h b/common/util.h index b92d78c4d..90acefa1a 100644 --- a/common/util.h +++ b/common/util.h @@ -152,26 +152,30 @@ #define snprintf gpgrt_snprintf -/* GCC attributes. */ -#ifndef GNUPG_GCC_ATTR_FORMAT_ARG -#if __GNUC__ >= 3 /* Actually 2.8 but testing the major is easier. */ -# define GNUPG_GCC_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a))) -#else -# define GNUPG_GCC_ATTR_FORMAT_ARG(a) -#endif -#endif +/* Replacements for macros not available with libgpg-error < 1.20. */ +#ifndef GPGRT_GCC_VERSION -#if __GNUC__ >= 4 -# define GNUPG_GCC_A_SENTINEL(a) __attribute__ ((sentinel(a))) -#else -# define GNUPG_GCC_A_SENTINEL(a) -#endif +# ifndef GPGRT_ATTR_FORMAT_ARG +# if __GNUC__ >= 3 /* Actually 2.8 but testing the major is easier. */ +# define GPGRT_ATTR_FORMAT_ARG(a) __attribute__ ((__format_arg__ (a))) +# else +# define GPGRT_ATTR_FORMAT_ARG(a) +# endif +# endif -#if __GNUC__ >= 4 -# define GNUPG_GCC_A_USED __attribute__ ((used)) -#else -# define GNUPG_GCC_A_USED -#endif +# if __GNUC__ >= 4 +# define GPGRT_ATTR_SENTINEL(a) __attribute__ ((sentinel(a))) +# else +# define GPGRT_ATTR_SENTINEL(a) +# endif + +# if __GNUC__ >= 4 +# define GPGRT_ATTR_USED __attribute__ ((used)) +# else +# define GPGRT_ATTR_USED +# endif + +#endif /*libgpg-error < 1.20 */ /* We need this type even if we are not using libreadline and or we @@ -371,9 +375,9 @@ const char *gnupg_messages_locale_name (void); void setup_libgcrypt_logging (void); /* Same as estream_asprintf but die on memory failure. */ -char *xasprintf (const char *fmt, ...) GPGRT_GCC_A_PRINTF(1,2); +char *xasprintf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); /* This is now an alias to estream_asprintf. */ -char *xtryasprintf (const char *fmt, ...) GPGRT_GCC_A_PRINTF(1,2); +char *xtryasprintf (const char *fmt, ...) GPGRT_ATTR_PRINTF(1,2); /* Replacement for gcry_cipher_algo_name. */ const char *gnupg_cipher_algo_name (int algo); |