[doc] NEWS
[lighttpd.git] / src / first.h
blobcaa19c149b71153db016bcc33a657af7fb63b4d3
1 #ifndef LI_FIRST_H
2 #define LI_FIRST_H
4 #ifdef HAVE_CONFIG_H
5 # include "config.h"
6 #else
7 # ifndef _GNU_SOURCE
8 # define _GNU_SOURCE
9 # endif
10 #endif
12 #ifndef __STDC_WANT_LIB_EXT1__
13 #define __STDC_WANT_LIB_EXT1__ 1
14 #endif
16 #ifdef __COVERITY__
17 #define _Float128 long double
18 #define _Float64x long double
19 #define _Float64 double
20 #define _Float32x double
21 #define _Float32 float
22 #endif
25 #include <sys/types.h>
26 #include <stddef.h>
28 #if defined HAVE_STDINT_H
29 # include <stdint.h>
30 #elif defined HAVE_INTTYPES_H
31 # include <inttypes.h>
32 #endif
35 /* solaris and NetBSD 1.3.x again */
36 #if (!defined(HAVE_STDINT_H)) && (!defined(HAVE_INTTYPES_H)) && (!defined(uint32_t))
37 # define uint32_t u_int32_t
38 #endif
41 #include <limits.h>
43 #ifndef SIZE_MAX
44 # ifdef SIZE_T_MAX
45 # define SIZE_MAX SIZE_T_MAX
46 # else
47 # define SIZE_MAX (~(size_t)0u)
48 # endif
49 #endif
51 #ifndef SSIZE_MAX
52 # define SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1))
53 #endif
56 #define UNUSED(x) ( (void)(x) )
59 #ifndef __has_attribute /* clang */
60 #define __has_attribute(x) 0
61 #endif
63 #ifdef __GNUC__
64 #ifndef __GNUC_PREREQ
65 # ifdef __GNUC_PREREQ__
66 # define __GNUC_PREREQ __GNUC_PREREQ__
67 # elif defined __GNUC__ && defined __GNUC_MINOR__
68 # define __GNUC_PREREQ(maj, min) \
69 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
70 # else
71 # define __GNUC_PREREQ(maj, min) 0
72 # endif
73 #endif
74 #else
75 #define __GNUC_PREREQ(maj,min) 0
76 #endif
78 #ifndef __attribute_noinline__
79 #if __has_attribute(noinline) \
80 || __GNUC_PREREQ(3,1)
81 #define __attribute_noinline__ __attribute__((__noinline__))
82 #else
83 #define __attribute_noinline__
84 #endif
85 #endif
87 #ifndef __attribute_cold__
88 #if __has_attribute(cold) \
89 || __GNUC_PREREQ(4,3)
90 #define __attribute_cold__ __attribute__((__cold__))
91 #else
92 #define __attribute_cold__
93 #endif
94 #endif
96 #ifndef __attribute_hot__
97 #if __has_attribute(hot) \
98 || __GNUC_PREREQ(4,3)
99 #define __attribute_hot__ __attribute__((__hot__))
100 #else
101 #define __attribute_hot__
102 #endif
103 #endif
105 #ifndef __attribute_noreturn__
106 #if __has_attribute(noreturn) \
107 || __GNUC_PREREQ(2,5)
108 #define __attribute_noreturn__ __attribute__((__noreturn__))
109 #else
110 #define __attribute_noreturn__
111 #endif
112 #endif
114 #ifndef __attribute_fallthrough__
115 #if __has_attribute(fallthrough) \
116 || __GNUC_PREREQ(7,0)
117 #define __attribute_fallthrough__ __attribute__((__fallthrough__));
118 #else
119 #define __attribute_fallthrough__ /* fall through */
120 #endif
121 #endif
123 #ifndef __attribute_format__
124 #if __has_attribute(format) \
125 || __GNUC_PREREQ(2,95) /*(maybe earlier gcc, too)*/
126 #define __attribute_format__(x) __attribute__((__format__ x))
127 #else
128 #define __attribute_format__(x)
129 #endif
130 #endif
133 #endif