Blob


1 #ifndef _U_H_
2 #define _U_H_ 1
3 #if defined(__cplusplus)
4 extern "C" {
5 #endif
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 #define _LARGEFILE64_SOURCE 1
33 #define _FILE_OFFSET_BITS 64
35 #include <inttypes.h>
37 #include <unistd.h>
38 #include <string.h>
39 #include <stdlib.h>
40 #include <stdarg.h>
41 #include <fcntl.h>
42 #include <assert.h>
43 #include <setjmp.h>
44 #include <stddef.h>
45 #include <math.h>
46 #include <ctype.h> /* for tolower */
48 /*
49 * OS-specific crap
50 */
51 #define _NEEDUCHAR 1
52 #define _NEEDUSHORT 1
53 #define _NEEDUINT 1
54 #define _NEEDULONG 1
56 typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
58 #if defined(__linux__)
59 # include <sys/types.h>
60 # if defined(__Linux26__)
61 # include <pthread.h>
62 # define PLAN9PORT_USING_PTHREADS 1
63 # endif
64 # if defined(__USE_MISC)
65 # undef _NEEDUSHORT
66 # undef _NEEDUINT
67 # undef _NEEDULONG
68 # endif
69 #elif defined(__sun__)
70 # include <sys/types.h>
71 # include <pthread.h>
72 # define PLAN9PORT_USING_PTHREADS 1
73 # undef _NEEDUSHORT
74 # undef _NEEDUINT
75 # undef _NEEDULONG
76 # define nil 0 /* no cast to void* */
77 #elif defined(__FreeBSD__)
78 # include <sys/types.h>
79 # include <osreldate.h>
80 # if __FreeBSD_version >= 500000
81 # define PLAN9PORT_USING_PTHREADS 1
82 # include <pthread.h>
83 # endif
84 # if !defined(_POSIX_SOURCE)
85 # undef _NEEDUSHORT
86 # undef _NEEDUINT
87 # endif
88 #elif defined(__APPLE__)
89 # include <sys/types.h>
90 # include <pthread.h>
91 # define PLAN9PORT_USING_PTHREADS 1
92 # if __GNUC__ < 4
93 # undef _NEEDUSHORT
94 # undef _NEEDUINT
95 # endif
96 # undef _ANSI_SOURCE
97 # undef _POSIX_C_SOURCE
98 # undef _XOPEN_SOURCE
99 # if !defined(NSIG)
100 # define NSIG 32
101 # endif
102 # define _NEEDLL 1
103 #elif defined(__NetBSD__)
104 # include <sched.h>
105 # include <sys/types.h>
106 # undef _NEEDUSHORT
107 # undef _NEEDUINT
108 # undef _NEEDULONG
109 #elif defined(__OpenBSD__)
110 # include <sys/types.h>
111 # undef _NEEDUSHORT
112 # undef _NEEDUINT
113 # undef _NEEDULONG
114 #else
115 /* No idea what system this is -- try some defaults */
116 # include <pthread.h>
117 # define PLAN9PORT_USING_PTHREADS 1
118 #endif
120 #ifndef O_DIRECT
121 #define O_DIRECT 0
122 #endif
124 typedef signed char schar;
126 #ifdef _NEEDUCHAR
127 typedef unsigned char uchar;
128 #endif
129 #ifdef _NEEDUSHORT
130 typedef unsigned short ushort;
131 #endif
132 #ifdef _NEEDUINT
133 typedef unsigned int uint;
134 #endif
135 #ifdef _NEEDULONG
136 typedef unsigned long ulong;
137 #endif
138 typedef unsigned long long uvlong;
139 typedef long long vlong;
141 typedef uint64_t u64int;
142 typedef int64_t s64int;
143 typedef uint8_t u8int;
144 typedef int8_t s8int;
145 typedef uint16_t u16int;
146 typedef int16_t s16int;
147 typedef uintptr_t uintptr;
148 typedef intptr_t intptr;
149 typedef uint32_t u32int;
150 typedef int32_t s32int;
152 #undef _NEEDUCHAR
153 #undef _NEEDUSHORT
154 #undef _NEEDUINT
155 #undef _NEEDULONG
157 /*
158 * Funny-named symbols to tip off 9l to autolink.
159 */
160 #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
161 #define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1;
163 /*
164 * Gcc is too smart for its own good.
165 */
166 #if defined(__GNUC__)
167 # undef strcmp /* causes way too many warnings */
168 # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
169 # undef AUTOLIB
170 # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
171 # undef AUTOFRAMEWORK
172 # define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak));
173 # else
174 # undef AUTOLIB
175 # define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
176 # undef AUTOFRAMEWORK
177 # define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused));
178 # endif
179 #endif
181 #if defined(__cplusplus)
183 #endif
184 #endif