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 # include <pthread.h>
70 # define PLAN9PORT_USING_PTHREADS 1
71 # if defined(__USE_MISC)
72 # undef _NEEDUSHORT
73 # undef _NEEDUINT
74 # undef _NEEDULONG
75 # endif
76 #elif defined(__sun__)
77 # include <sys/types.h>
78 # include <pthread.h>
79 # define PLAN9PORT_USING_PTHREADS 1
80 # undef _NEEDUSHORT
81 # undef _NEEDUINT
82 # undef _NEEDULONG
83 # define nil 0 /* no cast to void* */
84 #elif defined(__FreeBSD__)
85 # include <sys/types.h>
86 # include <osreldate.h>
87 # define PLAN9PORT_USING_PTHREADS 1
88 # include <pthread.h>
89 # if !defined(_POSIX_SOURCE)
90 # undef _NEEDUSHORT
91 # undef _NEEDUINT
92 # endif
93 #elif defined(__APPLE__)
94 # include <sys/types.h>
95 # include <pthread.h>
96 # define PLAN9PORT_USING_PTHREADS 1
97 # if __GNUC__ < 4
98 # undef _NEEDUSHORT
99 # undef _NEEDUINT
100 # endif
101 # undef _ANSI_SOURCE
102 # undef _POSIX_C_SOURCE
103 # undef _XOPEN_SOURCE
104 # if !defined(NSIG)
105 # define NSIG 32
106 # endif
107 # define _NEEDLL 1
108 #elif defined(__NetBSD__)
109 # include <sched.h>
110 # include <sys/types.h>
111 # undef _NEEDUSHORT
112 # undef _NEEDUINT
113 # undef _NEEDULONG
114 #elif defined(__OpenBSD__)
115 # include <sys/types.h>
116 # include <pthread.h>
117 # define PLAN9PORT_USING_PTHREADS 1
118 # undef _NEEDUSHORT
119 # undef _NEEDUINT
120 # undef _NEEDULONG
121 #else
122 /* No idea what system this is -- try some defaults */
123 # include <pthread.h>
124 # define PLAN9PORT_USING_PTHREADS 1
125 #endif
127 #ifndef O_DIRECT
128 #define O_DIRECT 0
129 #endif
131 typedef signed char schar;
133 #ifdef _NEEDUCHAR
134 typedef unsigned char uchar;
135 #endif
136 #ifdef _NEEDUSHORT
137 typedef unsigned short ushort;
138 #endif
139 #ifdef _NEEDUINT
140 typedef unsigned int uint;
141 #endif
142 #ifdef _NEEDULONG
143 typedef unsigned long ulong;
144 #endif
145 typedef unsigned long long uvlong;
146 typedef long long vlong;
148 typedef uvlong u64int;
149 typedef vlong s64int;
150 typedef uint8_t u8int;
151 typedef int8_t s8int;
152 typedef uint16_t u16int;
153 typedef int16_t s16int;
154 typedef uintptr_t uintptr;
155 typedef intptr_t intptr;
156 typedef uint u32int;
157 typedef int s32int;
159 typedef u32int uint32;
160 typedef s32int int32;
161 typedef u16int uint16;
162 typedef s16int int16;
163 typedef u64int uint64;
164 typedef s64int int64;
165 typedef u8int uint8;
166 typedef s8int int8;
168 #undef _NEEDUCHAR
169 #undef _NEEDUSHORT
170 #undef _NEEDUINT
171 #undef _NEEDULONG
173 /*
174 * Funny-named symbols to tip off 9l to autolink.
175 */
176 #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
177 #define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1;
179 /*
180 * Gcc is too smart for its own good.
181 */
182 #if defined(__GNUC__)
183 # undef strcmp /* causes way too many warnings */
184 # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
185 # undef AUTOLIB
186 # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
187 # undef AUTOFRAMEWORK
188 # define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak));
189 # else
190 # undef AUTOLIB
191 # define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
192 # undef AUTOFRAMEWORK
193 # define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused));
194 # endif
195 #endif
197 #if defined(__cplusplus)
199 #endif
200 #endif