apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

macros.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  Macros Header - Various useful macro definitions
6 
7  This source is placed in the Public Domain, do with it what you will
8  It was originally written by Brian C. White.
9 
10  ##################################################################### */
11  /*}}}*/
12 // Private header
13 #ifndef MACROS_H
14 #define MACROS_H
15 
16 /* Useful count macro, use on an array of things and it will return the
17  number of items in the array */
18 #define APT_ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
19 
20 // Flag Macros
21 #define FLAG(f) (1L << (f))
22 #define SETFLAG(v,f) ((v) |= FLAG(f))
23 #define CLRFLAG(v,f) ((v) &=~FLAG(f))
24 #define CHKFLAG(v,f) ((v) & FLAG(f) ? true : false)
25 
26 #ifdef __GNUC__
27 #define APT_GCC_VERSION (__GNUC__ << 8 | __GNUC_MINOR__)
28 #else
29 #define APT_GCC_VERSION 0
30 #endif
31 
32 #ifdef APT_COMPILING_APT
33 /* likely() and unlikely() can be used to mark boolean expressions
34  as (not) likely true which will help the compiler to optimise */
35 #if APT_GCC_VERSION >= 0x0300
36  #define likely(x) __builtin_expect (!!(x), 1)
37  #define unlikely(x) __builtin_expect (!!(x), 0)
38 #else
39  #define likely(x) (x)
40  #define unlikely(x) (x)
41 #endif
42 #endif
43 
44 #if APT_GCC_VERSION >= 0x0300
45  #define APT_DEPRECATED __attribute__ ((deprecated))
46  #define APT_DEPRECATED_MSG(X) __attribute__ ((deprecated(X)))
47  // __attribute__((const)) is too dangerous for us, we end up using it wrongly
48  #define APT_PURE __attribute__((pure))
49  #define APT_NORETURN __attribute__((noreturn))
50  #define APT_PRINTF(n) __attribute__((format(printf, n, n + 1)))
51  #define APT_WEAK __attribute__((weak));
52  #define APT_UNUSED __attribute__((unused))
53 #else
54  #define APT_DEPRECATED
55  #define APT_DEPRECATED_MSG
56  #define APT_PURE
57  #define APT_NORETURN
58  #define APT_PRINTF(n)
59  #define APT_WEAK
60  #define APT_UNUSED
61 #endif
62 
63 #if APT_GCC_VERSION > 0x0302
64  #define APT_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
65  #define APT_MUSTCHECK __attribute__((warn_unused_result))
66 #else
67  #define APT_NONNULL(...)
68  #define APT_MUSTCHECK
69 #endif
70 
71 #if APT_GCC_VERSION >= 0x0400
72  #define APT_SENTINEL __attribute__((sentinel))
73  #define APT_PUBLIC __attribute__ ((visibility ("default")))
74  #define APT_HIDDEN __attribute__ ((visibility ("hidden")))
75 #else
76  #define APT_SENTINEL
77  #define APT_PUBLIC
78  #define APT_HIDDEN
79 #endif
80 
81 // cold functions are unlikely() to be called
82 #if APT_GCC_VERSION >= 0x0403
83  #define APT_COLD __attribute__ ((__cold__))
84  #define APT_HOT __attribute__ ((__hot__))
85 #else
86  #define APT_COLD
87  #define APT_HOT
88 #endif
89 
90 
91 #if __GNUC__ >= 4
92  #define APT_IGNORE_DEPRECATED_PUSH \
93  _Pragma("GCC diagnostic push") \
94  _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
95  #define APT_IGNORE_DEPRECATED_POP \
96  _Pragma("GCC diagnostic pop")
97  /* gcc has various problems with this shortcut, so prefer the long form */
98  #define APT_IGNORE_DEPRECATED(XXX) \
99  APT_IGNORE_DEPRECATED_PUSH \
100  XXX \
101  APT_IGNORE_DEPRECATED_POP
102 #else
103  #define APT_IGNORE_DEPRECATED_PUSH
104  #define APT_IGNORE_DEPRECATED_POP
105  #define APT_IGNORE_DEPRECATED(XXX) XXX
106 #endif
107 
108 #if __cplusplus >= 201103L
109  #define APT_OVERRIDE override
110 #else
111  #define APT_OVERRIDE /* no c++11 standard */
112 #endif
113 
114 // These lines are extracted by the makefiles and the buildsystem
115 // Increasing MAJOR or MINOR results in the need of recompiling all
116 // reverse-dependencies of libapt-pkg against the new SONAME.
117 // Non-ABI-Breaks should only increase RELEASE number.
118 // See also buildlib/libversion.mak
119 #define APT_PKG_MAJOR 6
120 #define APT_PKG_MINOR 0
121 #define APT_PKG_RELEASE 0
122 #define APT_PKG_ABI ((APT_PKG_MAJOR * 100) + APT_PKG_MINOR)
123 
124 /* Should be a multiple of the common page size (4096) */
125 static constexpr unsigned long long APT_BUFFER_SIZE = 64 * 1024;
126 
127 #endif
static constexpr unsigned long long APT_BUFFER_SIZE
Definition: macros.h:125