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 # undef _NEEDUSHORT
120 # undef _NEEDUINT
121 # undef _NEEDULONG
122 #else
123 /* No idea what system this is -- try some defaults */
124 # include <pthread.h>
125 # define PLAN9PORT_USING_PTHREADS 1
126 #endif
128 #ifndef O_DIRECT
129 #define O_DIRECT 0
130 #endif
132 typedef signed char schar;
134 #ifdef _NEEDUCHAR
135 typedef unsigned char uchar;
136 #endif
137 #ifdef _NEEDUSHORT
138 typedef unsigned short ushort;
139 #endif
140 #ifdef _NEEDUINT
141 typedef unsigned int uint;
142 #endif
143 #ifdef _NEEDULONG
144 typedef unsigned long ulong;
145 #endif
146 typedef unsigned long long uvlong;
147 typedef long long vlong;
149 typedef uint64_t u64int;
150 typedef int64_t s64int;
151 typedef uint8_t u8int;
152 typedef int8_t s8int;
153 typedef uint16_t u16int;
154 typedef int16_t s16int;
155 typedef uintptr_t uintptr;
156 typedef intptr_t intptr;
157 typedef uint32_t u32int;
158 typedef int32_t s32int;
160 typedef u32int uint32;
161 typedef s32int int32;
162 typedef u16int uint16;
163 typedef s16int int16;
164 typedef u64int uint64;
165 typedef s64int int64;
166 typedef u8int uint8;
167 typedef s8int int8;
169 #undef _NEEDUCHAR
170 #undef _NEEDUSHORT
171 #undef _NEEDUINT
172 #undef _NEEDULONG
174 /*
175 * Funny-named symbols to tip off 9l to autolink.
176 */
177 #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
178 #define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1;
180 /*
181 * Gcc is too smart for its own good.
182 */
183 #if defined(__GNUC__)
184 # undef strcmp /* causes way too many warnings */
185 # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
186 # undef AUTOLIB
187 # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
188 # undef AUTOFRAMEWORK
189 # define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak));
190 # else
191 # undef AUTOLIB
192 # define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
193 # undef AUTOFRAMEWORK
194 # define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused));
195 # endif
196 #endif
198 #if defined(__cplusplus)
200 #endif
201 #endif