1 #ifndef __ZZIP_INTERNAL_HINTS_H
2 #define __ZZIP_INTERNAL_HINTS_H
5 #ifndef ZZIP_GNUC_ATLEAST
6 # if defined __GNUC__ && defined __GNUC_MINOR__
7 # define ZZIP_GNUC_ATLEAST(_M_,_N_) \
8 ((__GNUC__ << 10) + __GNUC_MINOR__ >= ((_M_) << 10) + (_N_))
9 # elif defined __GNUC__
10 # define ZZIP_GNUC_ATLEAST(_M_,_N_) \
11 ((__GNUC__ << 10) >= ((_M_) << 10))
13 # define ZZIP_GNUC_ATLEAST(_M_, _N_) 0
17 #ifndef ZZIP_GNUC_EXTENSION
18 # if ZZIP_GNUC_ATLEAST(2,8)
19 # define ZZIP_GNUC_EXTENSION __extension__
21 # define ZZIP_GNUC_EXTENSION
25 /* func has no side effects, return value depends only on params and globals */
26 #ifndef ZZIP_GNUC_PURE
27 # if ZZIP_GNUC_ATLEAST(2,8)
28 # define ZZIP_GNUC_PURE __attribute__((__pure__))
30 # define ZZIP_GNUC_PURE
34 /* func has no side effects, return value depends only on params */
35 #ifndef ZZIP_GNUC_CONST
36 # if ZZIP_GNUC_ATLEAST(2,4)
37 # define ZZIP_GNUC_CONST __attribute__((__const__))
39 # define ZZIP_GNUC_CONST
43 /* typename / variable / function possibly unused */
44 #ifndef ZZIP_GNUC_UNUSED
45 # if ZZIP_GNUC_ATLEAST(2,4)
46 # define ZZIP_GNUC_UNUSED __attribute__((__unused__))
48 # define ZZIP_GNUC_UNUSED
52 /* obvious. btw, a noreturn-func should return void */
53 #ifndef ZZIP_GNUC_NORETURN
54 # if ZZIP_GNUC_ATLEAST(2,5)
55 # define ZZIP_GNUC_NORETURN __attribute__((__noreturn__))
57 # define ZZIP_GNUC_NORETURN
61 /* omit function from profiling with -finstrument-functions */
62 #ifndef ZZIP_GNUC_NO_INSTRUMENT
63 # if ZZIP_GNUC_ATLEAST(2,4)
64 # define ZZIP_GNUC_NO_INSTRUMENT __attribute__((__no_instrument_function__))
66 # define ZZIP_GNUC_NO_INSTRUMENT
70 /* all pointer args must not be null, and allow optimiztons based on the fact*/
71 #ifndef ZZIP_GNUC_NONNULL
72 # if ZZIP_GNUC_ATLEAST(3,1)
73 # define ZZIP_GNUC_NONNULL __attribute__((nonnull))
75 # define ZZIP_GNUC_NONNULL
79 /* the function can not throw - the libc function are usually nothrow */
80 #ifndef ZZIP_GNUC_NOTHROW
81 # if ZZIP_GNUC_ATLEAST(3,2)
82 # define ZZIP_GNUC_NOTHROW __attribute__((nothrow))
84 # define ZZIP_GNUC_NOTHROW
88 /* typename / function / variable is obsolete but still listed in headers */
89 #ifndef ZZIP_GNUC_DEPRECATED
90 # if ZZIP_GNUC_ATLEAST(3,1)
91 # define ZZIP_GNUC_DEPRECATED __attribute__((deprecated))
93 # define ZZIP_GNUC_DEPRECATED
97 /* resolve references to this function during pre-linking the libary */
98 #ifndef ZZIP_GNUC_LIB_PROTECTED
99 # if ZZIP_GNUC_ATLEAST(3,1)
100 # define ZZIP_GNUC_LIB_PROTECTED __attribute__((visiblity("protected")))
102 # define ZZIP_GNUC_LIB_PROTECTED
106 /* func shall only be usable within the same lib (so, no entry in lib symtab)*/
107 #ifndef ZZIP_GNUC_LIB_PRIVATE
108 # if ZZIP_GNUC_ATLEAST(3,1)
109 # define ZZIP_GNUC_LIB_PRIVATE __attribute__((visiblity("hidden")))
111 # define ZZIP_GNUC_LIB_PRIVATE
115 /* ... and not even passed as a function pointer reference to outside the lib*/
116 #ifndef ZZIP_GNUC_LIB_INTERNAL
117 # if ZZIP_GNUC_ATLEAST(3,1)
118 # define ZZIP_GNUC_LIB_INTERNAL __attribute__((visiblity("internal")))
120 # define ZZIP_GNUC_LIB_INTERNAL
125 #ifndef ZZIP_GNUC_FORMAT
126 # if ZZIP_GNUC_ATLEAST(2,4)
127 # define ZZIP_GNUC_FORMAT(_X_) __attribute__((__format_arg__(_X_)))
129 # define ZZIP_GNUC_FORMAT(_X_)
133 #ifndef ZZIP_GNUC_SCANF
134 # if ZZIP_GNUC_ATLEAST(2,4)
135 # define ZZIP_GNUC_SCANF(_S_,_X_) __attribute__((__scanf__(_S_,_X_)))
137 # define ZZIP_GNUC_SCANF(_S_,_X_)
141 #ifndef ZZIP_GNUC_PRINTF
142 # if ZZIP_GNUC_ATLEAST(2,4)
143 # define ZZIP_GNUC_PRINTF(_S_,_X_) __attribute__((__printf__(_S_,_X_)))
145 # define ZZIP_GNUC_PRINTF(_S_,_X_)
150 #define ZZIP_GNUC_PACKED __attribute__((packed))
152 #define ZZIP_GNUC_PACKED
155 #ifndef ZZIP_FUNCTION
156 # if ZZIP_GNUC_ATLEAST(2,6)
157 # define ZZIP_FUNC __FUNCTION__
158 # define ZZIP_FUNCTION __FUNCTION__
159 # elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
160 # define ZZIP_FUNC __func__
161 # define ZZIP_FUNCTION ""
164 # define ZZIP_FUNCTION ""
169 #define ZZIP_STRING(_X_) ZZIP_STRING_(_X_)
170 #define ZZIP_STRING_(_Y_) #_Y_
174 #define ZZIP_DIM(_A_) (sizeof(_A_) / sizeof ((_A_)[0]))
177 #if !(defined ZZIP_FOR1 && defined ZZIP_END1)
178 # if defined sun || defined __sun__
179 # define ZZIP_FOR1 if (1)
180 # define ZZIP_END1 else (void)0
182 # define ZZIP_FOR1 do
183 # define ZZIP_END1 while (0)
187 #ifndef ZZIP_BRANCH_OVER
188 # if ZZIP_GNUC_ATLEAST(2,96)
189 # define ZZIP_BRANCH_OVER(_X_) __builtin_expect((_X_),0)
191 # define ZZIP_BRANCH_OVER(_X_) (_X_)