Go to the documentation of this file.
21#ifndef LIBDPKG_MACROS_H
22#define LIBDPKG_MACROS_H
30#ifndef LIBDPKG_VOLATILE_API
31#error "The libdpkg API is to be considered volatile, please read 'README.api'."
37#define DPKG_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__)
39#define DPKG_GCC_VERSION 0
42#if DPKG_GCC_VERSION >= 0x0300
43#define DPKG_ATTR_UNUSED __attribute__((unused))
44#define DPKG_ATTR_CONST __attribute__((const))
45#define DPKG_ATTR_PURE __attribute__((pure))
46#define DPKG_ATTR_MALLOC __attribute__((malloc))
47#define DPKG_ATTR_NORET __attribute__((noreturn))
48#define DPKG_ATTR_PRINTF(n) __attribute__((format(printf, n, n + 1)))
49#define DPKG_ATTR_VPRINTF(n) __attribute__((format(printf, n, 0)))
51#define DPKG_ATTR_UNUSED
52#define DPKG_ATTR_CONST
54#define DPKG_ATTR_MALLOC
55#define DPKG_ATTR_NORET
56#define DPKG_ATTR_PRINTF(n)
57#define DPKG_ATTR_VPRINTF(n)
60#if DPKG_GCC_VERSION > 0x0302
61#define DPKG_ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
62#define DPKG_ATTR_REQRET __attribute__((warn_unused_result))
64#define DPKG_ATTR_NONNULL(...)
65#define DPKG_ATTR_REQRET
68#if DPKG_GCC_VERSION >= 0x0400
69#define DPKG_ATTR_SENTINEL __attribute__((sentinel))
71#define DPKG_ATTR_SENTINEL
74#if defined(__cplusplus) && __cplusplus >= 201103L
75#define DPKG_ATTR_THROW(exception)
76#define DPKG_ATTR_NOEXCEPT noexcept
77#elif defined(__cplusplus)
78#define DPKG_ATTR_THROW(exception) throw(exception)
79#define DPKG_ATTR_NOEXCEPT throw()
83#define DPKG_BEGIN_DECLS extern "C" {
84#define DPKG_END_DECLS }
86#define DPKG_BEGIN_DECLS
99#if defined(__cplusplus)
100#define DPKG_NULL nullptr
102#define DPKG_NULL NULL
114#if defined(__cplusplus)
115#define DPKG_STATIC_CAST(type, expr) static_cast<type>(expr)
117#define DPKG_STATIC_CAST(type, expr) (type)(expr)
125#define DPKG_BIT(n) (1UL << (n))
133#define array_count(a) (sizeof(a) / sizeof((a)[0]))
139#define min(a, b) ((a) < (b) ? (a) : (b))
143#define max(a, b) ((a) > (b) ? (a) : (b))
159#define clamp(v, l, h) ((v) > (h) ? (h) : ((v) < (l) ? (l) : (v)))