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