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