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