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