- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# rpmutil.h

Go to the documentation of this file.

    00001 #ifndef _RPMUTIL_H
    00002 #define _RPMUTIL_H
    00003
    00004 /*
    00005  * Miscellanous utility macros:
    00006  * - portability wrappers for various gcc extensions like __attribute__()
    00007  * - ...
    00008  *
    00009  * Copied from glib, names replaced to avoid clashing with glib.
    00010  *
    00011  */
    00012
    00013 /* Here we provide RPM_GNUC_EXTENSION as an alias for __extension__,
    00014  * where this is valid. This allows for warningless compilation of
    00015  * "long long" types even in the presence of '-ansi -pedantic'.
    00016  */
    00017 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
    00018 #  define RPM_GNUC_EXTENSION __extension__
    00019 #else
    00020 #  define RPM_GNUC_EXTENSION
    00021 #endif
    00022
    00023 /* Provide macros to feature the GCC function attribute.
    00024  */
    00025 #if    __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
    00026 #define RPM_GNUC_PURE                            \
    00027   __attribute__((__pure__))
    00028 #define RPM_GNUC_MALLOC                         \
    00029   __attribute__((__malloc__))
    00030 #else
    00031 #define RPM_GNUC_PURE
    00032 #define RPM_GNUC_MALLOC
    00033 #endif
    00034
    00035 #if     __GNUC__ >= 4
    00036 #define RPM_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
    00037 #else
    00038 #define RPM_GNUC_NULL_TERMINATED
    00039 #endif
    00040
    00041 #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
    00042 #define RPM_GNUC_PRINTF( format_idx, arg_idx )    \
    00043   __attribute__((__format__ (__printf__, format_idx, arg_idx)))
    00044 #define RPM_GNUC_SCANF( format_idx, arg_idx )     \
    00045   __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
    00046 #define RPM_GNUC_FORMAT( arg_idx )                \
    00047   __attribute__((__format_arg__ (arg_idx)))
    00048 #define RPM_GNUC_NORETURN                         \
    00049   __attribute__((__noreturn__))
    00050 #define RPM_GNUC_CONST                            \
    00051   __attribute__((__const__))
    00052 #define RPM_GNUC_UNUSED                           \
    00053   __attribute__((__unused__))
    00054 #define RPM_GNUC_NO_INSTRUMENT                  \
    00055   __attribute__((__no_instrument_function__))
    00056 #else   /* !__GNUC__ */
    00057 #define RPM_GNUC_PRINTF( format_idx, arg_idx )
    00058 #define RPM_GNUC_SCANF( format_idx, arg_idx )
    00059 #define RPM_GNUC_FORMAT( arg_idx )
    00060 #define RPM_GNUC_NORETURN
    00061 #define RPM_GNUC_CONST
    00062 #define RPM_GNUC_UNUSED
    00063 #define RPM_GNUC_NO_INSTRUMENT
    00064 #endif  /* !__GNUC__ */
    00065
    00066 #if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
    00067 #define RPM_GNUC_DEPRECATED                            \
    00068   __attribute__((__deprecated__))
    00069 #else
    00070 #define RPM_GNUC_DEPRECATED
    00071 #endif /* __GNUC__ */
    00072
    00073 #if     __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
    00074 #  define RPM_GNUC_MAY_ALIAS __attribute__((may_alias))
    00075 #else
    00076 #  define RPM_GNUC_MAY_ALIAS
    00077 #endif
    00078
    00079 #if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
    00080 #define RPM_GNUC_WARN_UNUSED_RESULT             \
    00081   __attribute__((warn_unused_result))
    00082 #else
    00083 #define RPM_GNUC_WARN_UNUSED_RESULT
    00084 #endif /* __GNUC__ */
    00085
    00086 #if    __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
    00087 #  define RPM_GNUC_INTERNAL __attribute__((visibility("hidden")))
    00088 #else
    00089 #  define RPM_GNUC_INTERNAL
    00090 #endif
    00091
    00092
    00093 /* Guard C code in headers, while including them from C++ */
    00094 #ifdef  __cplusplus
    00095 # define RPM_BEGIN_DECLS  extern "C" {
    00096 # define RPM_END_DECLS    }
    00097 #else
    00098 # define RPM_BEGIN_DECLS
    00099 # define RPM_END_DECLS
    00100 #endif
    00101
    00102 #endif /* _RPMUTIL_H */