1 #ifndef LI_FIRST_H 2 #define LI_FIRST_H 3 4 #ifdef HAVE_CONFIG_H 5 # include "config.h" 6 #else 7 # ifndef _GNU_SOURCE 8 # define _GNU_SOURCE 9 # endif 10 #endif 11 12 #ifndef __STDC_WANT_LIB_EXT1__ 13 #define __STDC_WANT_LIB_EXT1__ 1 14 #endif 15 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 23 24 25 #include <sys/types.h> 26 #include <stddef.h> 27 28 #if defined HAVE_STDINT_H 29 # include <stdint.h> 30 #elif defined HAVE_INTTYPES_H 31 # include <inttypes.h> 32 #endif 33 34 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 39 40 41 #include <limits.h> 42 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 50 51 #ifndef SSIZE_MAX 52 # define SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1)) 53 #endif 54 55 56 #define UNUSED(x) ( (void)(x) ) 57 58 59 #ifndef __has_attribute /* clang */ 60 #define __has_attribute(x) 0 61 #endif 62 63 #ifndef __has_builtin /* clang */ 64 #define __has_builtin(x) 0 65 #endif 66 67 #ifdef __GNUC__ 68 #ifndef __GNUC_PREREQ 69 # ifdef __GNUC_PREREQ__ 70 # define __GNUC_PREREQ __GNUC_PREREQ__ 71 # elif defined __GNUC__ && defined __GNUC_MINOR__ 72 # define __GNUC_PREREQ(maj, min) \ 73 ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) 74 # else 75 # define __GNUC_PREREQ(maj, min) 0 76 # endif 77 #endif 78 #else 79 #define __GNUC_PREREQ(maj,min) 0 80 #endif 81 82 #ifndef __builtin_expect 83 #if !__has_builtin(__builtin_expect) \ 84 && !__GNUC_PREREQ(2,96) 85 #define __builtin_expect(x,y) (x) 86 #endif 87 #endif 88 89 #ifndef __attribute_noinline__ 90 #if __has_attribute(noinline) \ 91 || __GNUC_PREREQ(3,1) 92 #define __attribute_noinline__ __attribute__((__noinline__)) 93 #else 94 #define __attribute_noinline__ 95 #endif 96 #endif 97 98 #ifndef __attribute_cold__ 99 #if __has_attribute(cold) \ 100 || __GNUC_PREREQ(4,3) 101 #define __attribute_cold__ __attribute__((__cold__)) 102 #else 103 #define __attribute_cold__ 104 #endif 105 #endif 106 107 #ifndef __attribute_hot__ 108 #if __has_attribute(hot) \ 109 || __GNUC_PREREQ(4,3) 110 #define __attribute_hot__ __attribute__((__hot__)) 111 #else 112 #define __attribute_hot__ 113 #endif 114 #endif 115 116 #ifndef __attribute_noreturn__ 117 #if __has_attribute(noreturn) \ 118 || __GNUC_PREREQ(2,5) 119 #define __attribute_noreturn__ __attribute__((__noreturn__)) 120 #else 121 #define __attribute_noreturn__ 122 #endif 123 #endif 124 125 #ifndef __attribute_fallthrough__ 126 #if __has_attribute(fallthrough) \ 127 || __GNUC_PREREQ(7,0) 128 #define __attribute_fallthrough__ __attribute__((__fallthrough__)); 129 #else 130 #define __attribute_fallthrough__ /* fall through */ 131 #endif 132 #endif 133 134 #ifndef __attribute_format__ 135 #if __has_attribute(format) \ 136 || __GNUC_PREREQ(2,95) /*(maybe earlier gcc, too)*/ 137 #define __attribute_format__(x) __attribute__((__format__ x)) 138 #else 139 #define __attribute_format__(x) 140 #endif 141 #endif 142 143 #ifndef __attribute_pure__ 144 #if __has_attribute(pure) \ 145 || __GNUC_PREREQ(2,96) 146 #define __attribute_pure__ __attribute__((__pure__)) 147 #else 148 #define __attribute_pure__ 149 #endif 150 #endif 151 152 #ifndef __attribute_returns_nonnull__ 153 #if __has_attribute(returns_nonnull) \ 154 || __GNUC_PREREQ(4,9) 155 #define __attribute_returns_nonnull__ __attribute__((__returns_nonnull__)) 156 #else 157 #define __attribute_returns_nonnull__ 158 #endif 159 #endif 160 161 162 #endif 163