tu.h - plan9port - [fork] Plan 9 from user space | |
git clone git://src.adamsgaard.dk/plan9port | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
tu.h (4277B) | |
--- | |
1 // See ../src/lib9/LICENSE | |
2 | |
3 #ifndef _U_H_ | |
4 #define _U_H_ 1 | |
5 #if defined(__cplusplus) | |
6 extern "C" { | |
7 #endif | |
8 | |
9 #define HAS_SYS_TERMIOS 1 | |
10 | |
11 #define __BSD_VISIBLE 1 /* FreeBSD 5.x */ | |
12 #if defined(__sun__) | |
13 # define __EXTENSIONS__ 1 /* SunOS */ | |
14 # if defined(__SunOS5_6__) || defined(__SunOS5_7__) || defined(__… | |
15 /* NOT USING #define __MAKECONTEXT_V2_SOURCE 1 / * SunOS… | |
16 # else | |
17 /* What's left? */ | |
18 # define __MAKECONTEXT_V2_SOURCE 1 | |
19 # endif | |
20 #endif | |
21 #define _BSD_SOURCE 1 | |
22 #define _NETBSD_SOURCE 1 /* NetBSD */ | |
23 #define _SVID_SOURCE 1 | |
24 #define _DEFAULT_SOURCE 1 | |
25 #if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__AIX__) | |
26 # define _XOPEN_SOURCE 1000 | |
27 # define _XOPEN_SOURCE_EXTENDED 1 | |
28 #endif | |
29 #if defined(__FreeBSD__) | |
30 # include <sys/cdefs.h> | |
31 /* for strtoll */ | |
32 # undef __ISO_C_VISIBLE | |
33 # define __ISO_C_VISIBLE 1999 | |
34 # undef __LONG_LONG_SUPPORTED | |
35 # define __LONG_LONG_SUPPORTED | |
36 #endif | |
37 #if defined(__AIX__) | |
38 # define _ALL_SOURCE | |
39 # undef HAS_SYS_TERMIOS | |
40 #endif | |
41 #define _LARGEFILE64_SOURCE 1 | |
42 #define _FILE_OFFSET_BITS 64 | |
43 | |
44 #include <inttypes.h> | |
45 | |
46 #include <unistd.h> | |
47 #include <string.h> | |
48 #include <stdlib.h> | |
49 #include <stdarg.h> | |
50 #include <fcntl.h> | |
51 #include <assert.h> | |
52 #include <setjmp.h> | |
53 #include <stddef.h> | |
54 #include <math.h> | |
55 #include <ctype.h> /* for tolower */ | |
56 | |
57 /* | |
58 * OS-specific crap | |
59 */ | |
60 #define _NEEDUCHAR 1 | |
61 #define _NEEDUSHORT 1 | |
62 #define _NEEDUINT 1 | |
63 #define _NEEDULONG 1 | |
64 | |
65 typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)]; | |
66 | |
67 #if defined(__linux__) | |
68 # include <sys/types.h> | |
69 # include <pthread.h> | |
70 # if defined(__USE_MISC) | |
71 # undef _NEEDUSHORT | |
72 # undef _NEEDUINT | |
73 # undef _NEEDULONG | |
74 # endif | |
75 #elif defined(__sun__) | |
76 # include <sys/types.h> | |
77 # include <pthread.h> | |
78 # undef _NEEDUSHORT | |
79 # undef _NEEDUINT | |
80 # undef _NEEDULONG | |
81 # define nil 0 /* no cast to void* */ | |
82 #elif defined(__FreeBSD__) | |
83 # include <sys/types.h> | |
84 # include <osreldate.h> | |
85 # include <pthread.h> | |
86 # if !defined(_POSIX_SOURCE) | |
87 # undef _NEEDUSHORT | |
88 # undef _NEEDUINT | |
89 # endif | |
90 #elif defined(__APPLE__) | |
91 # include <sys/types.h> | |
92 # include <pthread.h> | |
93 # if __GNUC__ < 4 | |
94 # undef _NEEDUSHORT | |
95 # undef _NEEDUINT | |
96 # endif | |
97 # undef _ANSI_SOURCE | |
98 # undef _POSIX_C_SOURCE | |
99 # undef _XOPEN_SOURCE | |
100 # if !defined(NSIG) | |
101 # define NSIG 32 | |
102 # endif | |
103 # define _NEEDLL 1 | |
104 #elif defined(__NetBSD__) | |
105 # include <sched.h> | |
106 # include <sys/types.h> | |
107 # include <pthread.h> | |
108 # undef _NEEDUSHORT | |
109 # undef _NEEDUINT | |
110 # undef _NEEDULONG | |
111 #elif defined(__OpenBSD__) | |
112 # include <sys/types.h> | |
113 # include <pthread.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 #endif | |
121 | |
122 #ifndef O_DIRECT | |
123 #define O_DIRECT 0 | |
124 #endif | |
125 | |
126 typedef signed char schar; | |
127 | |
128 #ifdef _NEEDUCHAR | |
129 typedef unsigned char uchar; | |
130 #endif | |
131 #ifdef _NEEDUSHORT | |
132 typedef unsigned short ushort; | |
133 #endif | |
134 #ifdef _NEEDUINT | |
135 typedef unsigned int uint; | |
136 #endif | |
137 #ifdef _NEEDULONG | |
138 typedef unsigned long ulong; | |
139 #endif | |
140 typedef unsigned long long uvlong; | |
141 typedef long long vlong; | |
142 | |
143 typedef uvlong u64int; | |
144 typedef vlong s64int; | |
145 typedef uint8_t u8int; | |
146 typedef int8_t s8int; | |
147 typedef uint16_t u16int; | |
148 typedef int16_t s16int; | |
149 typedef uintptr_t uintptr; | |
150 typedef intptr_t intptr; | |
151 typedef uint u32int; | |
152 typedef int s32int; | |
153 | |
154 typedef u32int uint32; | |
155 typedef s32int int32; | |
156 typedef u16int uint16; | |
157 typedef s16int int16; | |
158 typedef u64int uint64; | |
159 typedef s64int int64; | |
160 typedef u8int uint8; | |
161 typedef s8int int8; | |
162 | |
163 #undef _NEEDUCHAR | |
164 #undef _NEEDUSHORT | |
165 #undef _NEEDUINT | |
166 #undef _NEEDULONG | |
167 | |
168 /* | |
169 * Funny-named symbols to tip off 9l to autolink. | |
170 */ | |
171 #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1; | |
172 #define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1; | |
173 | |
174 /* | |
175 * Gcc is too smart for its own good. | |
176 */ | |
177 #if defined(__GNUC__) | |
178 # undef strcmp /* causes way too many warnings */ | |
179 # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__)) | |
180 # undef AUTOLIB | |
181 # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__… | |
182 # undef AUTOFRAMEWORK | |
183 # define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x _… | |
184 # else | |
185 # undef AUTOLIB | |
186 # define AUTOLIB(x) static int __p9l_autolib_ ## x __attr… | |
187 # undef AUTOFRAMEWORK | |
188 # define AUTOFRAMEWORK(x) static int __p9l_autoframework_… | |
189 # endif | |
190 #endif | |
191 | |
192 #if defined(__cplusplus) | |
193 } | |
194 #endif | |
195 #endif |