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