Blob


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