u.h (4287B)
1 #ifndef _U_H_ 2 #define _U_H_ 1 3 #if defined(__cplusplus) 4 extern "C" { 5 #endif 6 7 #define __BSD_VISIBLE 1 /* FreeBSD 5.x */ 8 #if defined(__sun__) 9 # define __EXTENSIONS__ 1 /* SunOS */ 10 # if defined(__SunOS5_6__) || defined(__SunOS5_7__) || defined(__SunOS5_8__) || defined(__SunOS5_9__) || defined(__SunOS5_10__) 11 /* NOT USING #define __MAKECONTEXT_V2_SOURCE 1 / * SunOS */ 12 # else 13 /* What's left? */ 14 # define __MAKECONTEXT_V2_SOURCE 1 15 # endif 16 #endif 17 #define _BSD_SOURCE 1 18 #define _NETBSD_SOURCE 1 /* NetBSD */ 19 #define _SVID_SOURCE 1 20 #if !defined(__APPLE__) && !defined(__OpenBSD__) 21 # define _XOPEN_SOURCE 1000 22 # define _XOPEN_SOURCE_EXTENDED 1 23 #endif 24 #if defined(__FreeBSD__) 25 # include <sys/cdefs.h> 26 /* for strtoll */ 27 # undef __ISO_C_VISIBLE 28 # define __ISO_C_VISIBLE 1999 29 # undef __LONG_LONG_SUPPORTED 30 # define __LONG_LONG_SUPPORTED 31 #endif 32 #if defined(__AIX__) 33 # define _XOPEN_SOURCE 1 34 #endif 35 #if defined(__APPLE__) 36 # define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */ 37 #endif 38 #define _LARGEFILE64_SOURCE 1 39 #define _FILE_OFFSET_BITS 64 40 41 #include <inttypes.h> 42 43 #include <unistd.h> 44 #include <string.h> 45 #include <stdlib.h> 46 #include <stdarg.h> 47 #include <fcntl.h> 48 #include <assert.h> 49 #include <setjmp.h> 50 #include <stddef.h> 51 #include <math.h> 52 #include <ctype.h> /* for tolower */ 53 54 /* 55 * OS-specific crap 56 */ 57 #define _NEEDUCHAR 1 58 #define _NEEDUSHORT 1 59 #define _NEEDUINT 1 60 #define _NEEDULONG 1 61 62 typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; 63 64 #if defined(__linux__) 65 # include <sys/types.h> 66 # if defined(__Linux26__) 67 # include <pthread.h> 68 # define PLAN9PORT_USING_PTHREADS 1 69 # endif 70 # if defined(__USE_MISC) 71 # undef _NEEDUSHORT 72 # undef _NEEDUINT 73 # undef _NEEDULONG 74 # endif 75 #elif defined(__sun__) 76 # include <sys/types.h> 77 # include <pthread.h> 78 # define PLAN9PORT_USING_PTHREADS 1 79 # undef _NEEDUSHORT 80 # undef _NEEDUINT 81 # undef _NEEDULONG 82 # define nil 0 /* no cast to void* */ 83 #elif defined(__FreeBSD__) 84 # include <sys/types.h> 85 # include <osreldate.h> 86 # if __FreeBSD_version >= 500000 87 # define PLAN9PORT_USING_PTHREADS 1 88 # include <pthread.h> 89 # endif 90 # if !defined(_POSIX_SOURCE) 91 # undef _NEEDUSHORT 92 # undef _NEEDUINT 93 # endif 94 #elif defined(__APPLE__) 95 # include <sys/types.h> 96 # include <pthread.h> 97 # define PLAN9PORT_USING_PTHREADS 1 98 # if __GNUC__ < 4 99 # undef _NEEDUSHORT 100 # undef _NEEDUINT 101 # endif 102 # undef _ANSI_SOURCE 103 # undef _POSIX_C_SOURCE 104 # undef _XOPEN_SOURCE 105 # if !defined(NSIG) 106 # define NSIG 32 107 # endif 108 # define _NEEDLL 1 109 #elif defined(__NetBSD__) 110 # include <sched.h> 111 # include <sys/types.h> 112 # undef _NEEDUSHORT 113 # undef _NEEDUINT 114 # undef _NEEDULONG 115 #elif defined(__OpenBSD__) 116 # include <sys/types.h> 117 # undef _NEEDUSHORT 118 # undef _NEEDUINT 119 # undef _NEEDULONG 120 #else 121 /* No idea what system this is -- try some defaults */ 122 # include <pthread.h> 123 # define PLAN9PORT_USING_PTHREADS 1 124 #endif 125 126 #ifndef O_DIRECT 127 #define O_DIRECT 0 128 #endif 129 130 typedef signed char schar; 131 132 #ifdef _NEEDUCHAR 133 typedef unsigned char uchar; 134 #endif 135 #ifdef _NEEDUSHORT 136 typedef unsigned short ushort; 137 #endif 138 #ifdef _NEEDUINT 139 typedef unsigned int uint; 140 #endif 141 #ifdef _NEEDULONG 142 typedef unsigned long ulong; 143 #endif 144 typedef unsigned long long uvlong; 145 typedef long long vlong; 146 147 typedef uint64_t u64int; 148 typedef int64_t s64int; 149 typedef uint8_t u8int; 150 typedef int8_t s8int; 151 typedef uint16_t u16int; 152 typedef int16_t s16int; 153 typedef uintptr_t uintptr; 154 typedef intptr_t intptr; 155 typedef uint32_t u32int; 156 typedef int32_t s32int; 157 158 #undef _NEEDUCHAR 159 #undef _NEEDUSHORT 160 #undef _NEEDUINT 161 #undef _NEEDULONG 162 163 /* 164 * Funny-named symbols to tip off 9l to autolink. 165 */ 166 #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1; 167 #define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1; 168 169 /* 170 * Gcc is too smart for its own good. 171 */ 172 #if defined(__GNUC__) 173 # undef strcmp /* causes way too many warnings */ 174 # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__)) 175 # undef AUTOLIB 176 # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak)); 177 # undef AUTOFRAMEWORK 178 # define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak)); 179 # else 180 # undef AUTOLIB 181 # define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused)); 182 # undef AUTOFRAMEWORK 183 # define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused)); 184 # endif 185 #endif 186 187 #if defined(__cplusplus) 188 } 189 #endif 190 #endif