diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-02-25 11:02:07 +0200 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-02-25 11:02:07 +0200 |
commit | c46876daa4358849de73a059d944f753a7584013 (patch) | |
tree | 8e9ca23e6b8cdd6bd7f2d80e9e950755a8364bdd /rpmio/rpmutil.h | |
parent | fe35727d3f55f830d21b71b183ea24974a02696f (diff) | |
download | librpm-tizen-c46876daa4358849de73a059d944f753a7584013.tar.gz librpm-tizen-c46876daa4358849de73a059d944f753a7584013.tar.bz2 librpm-tizen-c46876daa4358849de73a059d944f753a7584013.zip |
Add new header for collecting utility macros
- atm consists of portability wrappers to various gcc extensions like
__attribute__() to provide additional warnings and checks
- copied from glib to avoid an extra build dependency just for the silly
macros, renamed to avoid namespace clashing
Diffstat (limited to 'rpmio/rpmutil.h')
-rw-r--r-- | rpmio/rpmutil.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/rpmio/rpmutil.h b/rpmio/rpmutil.h new file mode 100644 index 000000000..325ee0ef7 --- /dev/null +++ b/rpmio/rpmutil.h @@ -0,0 +1,95 @@ +#ifndef _RPMUTIL_H +#define _RPMUTIL_H + +/* + * Miscellanous utility macros: + * - portability wrappers for various gcc extensions like __attribute__() + * - ... + * + * Copied from glib, names replaced to avoid clashing with glib. + * + */ + +/* Here we provide RPM_GNUC_EXTENSION as an alias for __extension__, + * where this is valid. This allows for warningless compilation of + * "long long" types even in the presence of '-ansi -pedantic'. + */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) +# define RPM_GNUC_EXTENSION __extension__ +#else +# define RPM_GNUC_EXTENSION +#endif + +/* Provide macros to feature the GCC function attribute. + */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#define RPM_GNUC_PURE \ + __attribute__((__pure__)) +#define RPM_GNUC_MALLOC \ + __attribute__((__malloc__)) +#else +#define RPM_GNUC_PURE +#define RPM_GNUC_MALLOC +#endif + +#if __GNUC__ >= 4 +#define RPM_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) +#else +#define RPM_GNUC_NULL_TERMINATED +#endif + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define RPM_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#define RPM_GNUC_SCANF( format_idx, arg_idx ) \ + __attribute__((__format__ (__scanf__, format_idx, arg_idx))) +#define RPM_GNUC_FORMAT( arg_idx ) \ + __attribute__((__format_arg__ (arg_idx))) +#define RPM_GNUC_NORETURN \ + __attribute__((__noreturn__)) +#define RPM_GNUC_CONST \ + __attribute__((__const__)) +#define RPM_GNUC_UNUSED \ + __attribute__((__unused__)) +#define RPM_GNUC_NO_INSTRUMENT \ + __attribute__((__no_instrument_function__)) +#else /* !__GNUC__ */ +#define RPM_GNUC_PRINTF( format_idx, arg_idx ) +#define RPM_GNUC_SCANF( format_idx, arg_idx ) +#define RPM_GNUC_FORMAT( arg_idx ) +#define RPM_GNUC_NORETURN +#define RPM_GNUC_CONST +#define RPM_GNUC_UNUSED +#define RPM_GNUC_NO_INSTRUMENT +#endif /* !__GNUC__ */ + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#define RPM_GNUC_DEPRECATED \ + __attribute__((__deprecated__)) +#else +#define RPM_GNUC_DEPRECATED +#endif /* __GNUC__ */ + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) +# define RPM_GNUC_MAY_ALIAS __attribute__((may_alias)) +#else +# define RPM_GNUC_MAY_ALIAS +#endif + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +#define RPM_GNUC_WARN_UNUSED_RESULT \ + __attribute__((warn_unused_result)) +#else +#define RPM_GNUC_WARN_UNUSED_RESULT +#endif /* __GNUC__ */ + +/* Guard C code in headers, while including them from C++ */ +#ifdef __cplusplus +# define RPM_BEGIN_DECLS extern "C" { +# define RPM_END_DECLS } +#else +# define RPM_BEGIN_DECLS +# define RPM_END_DECLS +#endif + +#endif /* _RPMUTIL_H */ |