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