Blame


1 c8ae41fb 2009-08-15 rsc // See ../src/lib9/LICENSE
2 c8ae41fb 2009-08-15 rsc
3 8ad51794 2004-03-25 devnull #ifndef _U_H_
4 8ad51794 2004-03-25 devnull #define _U_H_ 1
5 8ad51794 2004-03-25 devnull #if defined(__cplusplus)
6 8ad51794 2004-03-25 devnull extern "C" {
7 8ad51794 2004-03-25 devnull #endif
8 8ad51794 2004-03-25 devnull
9 39b3054a 2004-12-25 devnull #define __BSD_VISIBLE 1 /* FreeBSD 5.x */
10 d08f4066 2005-07-27 devnull #if defined(__sun__)
11 d08f4066 2005-07-27 devnull # define __EXTENSIONS__ 1 /* SunOS */
12 f12ab349 2008-07-20 devnull # if defined(__SunOS5_6__) || defined(__SunOS5_7__) || defined(__SunOS5_8__) || defined(__SunOS5_9__) || defined(__SunOS5_10__)
13 d08f4066 2005-07-27 devnull /* NOT USING #define __MAKECONTEXT_V2_SOURCE 1 / * SunOS */
14 d08f4066 2005-07-27 devnull # else
15 f12ab349 2008-07-20 devnull /* What's left? */
16 d08f4066 2005-07-27 devnull # define __MAKECONTEXT_V2_SOURCE 1
17 d08f4066 2005-07-27 devnull # endif
18 d08f4066 2005-07-27 devnull #endif
19 8ad51794 2004-03-25 devnull #define _BSD_SOURCE 1
20 5ba33c04 2005-03-28 devnull #define _NETBSD_SOURCE 1 /* NetBSD */
21 8ad51794 2004-03-25 devnull #define _SVID_SOURCE 1
22 20e8b903 2005-07-20 devnull #if !defined(__APPLE__) && !defined(__OpenBSD__)
23 a8ec4910 2005-07-13 devnull # define _XOPEN_SOURCE 1000
24 a8ec4910 2005-07-13 devnull # define _XOPEN_SOURCE_EXTENDED 1
25 a8ec4910 2005-07-13 devnull #endif
26 838874f0 2006-04-04 devnull #if defined(__FreeBSD__)
27 838874f0 2006-04-04 devnull # include <sys/cdefs.h>
28 838874f0 2006-04-04 devnull /* for strtoll */
29 838874f0 2006-04-04 devnull # undef __ISO_C_VISIBLE
30 838874f0 2006-04-04 devnull # define __ISO_C_VISIBLE 1999
31 838874f0 2006-04-04 devnull # undef __LONG_LONG_SUPPORTED
32 838874f0 2006-04-04 devnull # define __LONG_LONG_SUPPORTED
33 838874f0 2006-04-04 devnull #endif
34 e6c837d6 2009-07-15 rsc #if defined(__AIX__)
35 e6c837d6 2009-07-15 rsc # define _XOPEN_SOURCE 1
36 e6c837d6 2009-07-15 rsc #endif
37 37c94859 2009-09-13 rsc #if defined(__APPLE__)
38 37c94859 2009-09-13 rsc # define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */
39 37c94859 2009-09-13 rsc #endif
40 8ad51794 2004-03-25 devnull #define _LARGEFILE64_SOURCE 1
41 8ad51794 2004-03-25 devnull #define _FILE_OFFSET_BITS 64
42 8ad51794 2004-03-25 devnull
43 20e8b903 2005-07-20 devnull #include <inttypes.h>
44 76e02e9b 2005-07-19 devnull
45 8ad51794 2004-03-25 devnull #include <unistd.h>
46 8ad51794 2004-03-25 devnull #include <string.h>
47 8ad51794 2004-03-25 devnull #include <stdlib.h>
48 8ad51794 2004-03-25 devnull #include <stdarg.h>
49 8ad51794 2004-03-25 devnull #include <fcntl.h>
50 8ad51794 2004-03-25 devnull #include <assert.h>
51 8ad51794 2004-03-25 devnull #include <setjmp.h>
52 8ad51794 2004-03-25 devnull #include <stddef.h>
53 8ad51794 2004-03-25 devnull #include <math.h>
54 c8af1ab1 2004-04-19 devnull #include <ctype.h> /* for tolower */
55 8ad51794 2004-03-25 devnull
56 8ad51794 2004-03-25 devnull /*
57 8ad51794 2004-03-25 devnull * OS-specific crap
58 8ad51794 2004-03-25 devnull */
59 8ad51794 2004-03-25 devnull #define _NEEDUCHAR 1
60 8ad51794 2004-03-25 devnull #define _NEEDUSHORT 1
61 8ad51794 2004-03-25 devnull #define _NEEDUINT 1
62 8ad51794 2004-03-25 devnull #define _NEEDULONG 1
63 8ad51794 2004-03-25 devnull
64 8ad51794 2004-03-25 devnull typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
65 8ad51794 2004-03-25 devnull
66 8ad51794 2004-03-25 devnull #if defined(__linux__)
67 8ad51794 2004-03-25 devnull # include <sys/types.h>
68 aaa502d3 2005-03-15 devnull # if defined(__Linux26__)
69 aaa502d3 2005-03-15 devnull # include <pthread.h>
70 aaa502d3 2005-03-15 devnull # define PLAN9PORT_USING_PTHREADS 1
71 aaa502d3 2005-03-15 devnull # endif
72 8ad51794 2004-03-25 devnull # if defined(__USE_MISC)
73 8ad51794 2004-03-25 devnull # undef _NEEDUSHORT
74 8ad51794 2004-03-25 devnull # undef _NEEDUINT
75 8ad51794 2004-03-25 devnull # undef _NEEDULONG
76 8ad51794 2004-03-25 devnull # endif
77 39b3054a 2004-12-25 devnull #elif defined(__sun__)
78 8ad51794 2004-03-25 devnull # include <sys/types.h>
79 aaa502d3 2005-03-15 devnull # include <pthread.h>
80 aaa502d3 2005-03-15 devnull # define PLAN9PORT_USING_PTHREADS 1
81 8ad51794 2004-03-25 devnull # undef _NEEDUSHORT
82 8ad51794 2004-03-25 devnull # undef _NEEDUINT
83 8ad51794 2004-03-25 devnull # undef _NEEDULONG
84 aaa502d3 2005-03-15 devnull # define nil 0 /* no cast to void* */
85 39b3054a 2004-12-25 devnull #elif defined(__FreeBSD__)
86 8ad51794 2004-03-25 devnull # include <sys/types.h>
87 7ee1ac96 2004-12-29 devnull # include <osreldate.h>
88 aaa502d3 2005-03-15 devnull # if __FreeBSD_version >= 500000
89 aaa502d3 2005-03-15 devnull # define PLAN9PORT_USING_PTHREADS 1
90 aaa502d3 2005-03-15 devnull # include <pthread.h>
91 aaa502d3 2005-03-15 devnull # endif
92 8ad51794 2004-03-25 devnull # if !defined(_POSIX_SOURCE)
93 8ad51794 2004-03-25 devnull # undef _NEEDUSHORT
94 8ad51794 2004-03-25 devnull # undef _NEEDUINT
95 8ad51794 2004-03-25 devnull # endif
96 39b3054a 2004-12-25 devnull #elif defined(__APPLE__)
97 8ad51794 2004-03-25 devnull # include <sys/types.h>
98 aaa502d3 2005-03-15 devnull # include <pthread.h>
99 aaa502d3 2005-03-15 devnull # define PLAN9PORT_USING_PTHREADS 1
100 bc7da029 2005-05-07 devnull # if __GNUC__ < 4
101 bc7da029 2005-05-07 devnull # undef _NEEDUSHORT
102 bc7da029 2005-05-07 devnull # undef _NEEDUINT
103 bc7da029 2005-05-07 devnull # endif
104 bc7da029 2005-05-07 devnull # undef _ANSI_SOURCE
105 bc7da029 2005-05-07 devnull # undef _POSIX_C_SOURCE
106 a8ec4910 2005-07-13 devnull # undef _XOPEN_SOURCE
107 bc7da029 2005-05-07 devnull # if !defined(NSIG)
108 bc7da029 2005-05-07 devnull # define NSIG 32
109 bc7da029 2005-05-07 devnull # endif
110 8ad51794 2004-03-25 devnull # define _NEEDLL 1
111 5ba33c04 2005-03-28 devnull #elif defined(__NetBSD__)
112 5ba33c04 2005-03-28 devnull # include <sched.h>
113 5ba33c04 2005-03-28 devnull # include <sys/types.h>
114 5ba33c04 2005-03-28 devnull # undef _NEEDUSHORT
115 5ba33c04 2005-03-28 devnull # undef _NEEDUINT
116 5ba33c04 2005-03-28 devnull # undef _NEEDULONG
117 52e61644 2005-05-01 devnull #elif defined(__OpenBSD__)
118 ceb21b8a 2005-07-19 devnull # include <sys/types.h>
119 20f5692b 2012-07-14 rsc # include <pthread.h>
120 20f5692b 2012-07-14 rsc # define PLAN9PORT_USING_PTHREADS 1
121 52e61644 2005-05-01 devnull # undef _NEEDUSHORT
122 52e61644 2005-05-01 devnull # undef _NEEDUINT
123 52e61644 2005-05-01 devnull # undef _NEEDULONG
124 39b3054a 2004-12-25 devnull #else
125 39b3054a 2004-12-25 devnull /* No idea what system this is -- try some defaults */
126 aaa502d3 2005-03-15 devnull # include <pthread.h>
127 39b3054a 2004-12-25 devnull # define PLAN9PORT_USING_PTHREADS 1
128 8ad51794 2004-03-25 devnull #endif
129 8ad51794 2004-03-25 devnull
130 39b3054a 2004-12-25 devnull #ifndef O_DIRECT
131 39b3054a 2004-12-25 devnull #define O_DIRECT 0
132 39b3054a 2004-12-25 devnull #endif
133 06bb4ed2 2004-09-17 devnull
134 8ad51794 2004-03-25 devnull typedef signed char schar;
135 785a7364 2004-04-19 devnull
136 8ad51794 2004-03-25 devnull #ifdef _NEEDUCHAR
137 8ad51794 2004-03-25 devnull typedef unsigned char uchar;
138 8ad51794 2004-03-25 devnull #endif
139 8ad51794 2004-03-25 devnull #ifdef _NEEDUSHORT
140 8ad51794 2004-03-25 devnull typedef unsigned short ushort;
141 8ad51794 2004-03-25 devnull #endif
142 8ad51794 2004-03-25 devnull #ifdef _NEEDUINT
143 8ad51794 2004-03-25 devnull typedef unsigned int uint;
144 8ad51794 2004-03-25 devnull #endif
145 8ad51794 2004-03-25 devnull #ifdef _NEEDULONG
146 8ad51794 2004-03-25 devnull typedef unsigned long ulong;
147 8ad51794 2004-03-25 devnull #endif
148 8ad51794 2004-03-25 devnull typedef unsigned long long uvlong;
149 8ad51794 2004-03-25 devnull typedef long long vlong;
150 8ad51794 2004-03-25 devnull
151 443d6288 2012-02-19 rsc typedef uvlong u64int;
152 443d6288 2012-02-19 rsc typedef vlong s64int;
153 76e02e9b 2005-07-19 devnull typedef uint8_t u8int;
154 76e02e9b 2005-07-19 devnull typedef int8_t s8int;
155 76e02e9b 2005-07-19 devnull typedef uint16_t u16int;
156 76e02e9b 2005-07-19 devnull typedef int16_t s16int;
157 76e02e9b 2005-07-19 devnull typedef uintptr_t uintptr;
158 949b59cd 2008-03-06 rsc typedef intptr_t intptr;
159 443d6288 2012-02-19 rsc typedef uint u32int;
160 443d6288 2012-02-19 rsc typedef int s32int;
161 76e02e9b 2005-07-19 devnull
162 9a054520 2010-02-08 rsc typedef u32int uint32;
163 9a054520 2010-02-08 rsc typedef s32int int32;
164 9a054520 2010-02-08 rsc typedef u16int uint16;
165 9a054520 2010-02-08 rsc typedef s16int int16;
166 9a054520 2010-02-08 rsc typedef u64int uint64;
167 9a054520 2010-02-08 rsc typedef s64int int64;
168 8377cc7a 2010-07-14 rsc typedef u8int uint8;
169 8377cc7a 2010-07-14 rsc typedef s8int int8;
170 9a054520 2010-02-08 rsc
171 8ad51794 2004-03-25 devnull #undef _NEEDUCHAR
172 8ad51794 2004-03-25 devnull #undef _NEEDUSHORT
173 8ad51794 2004-03-25 devnull #undef _NEEDUINT
174 8ad51794 2004-03-25 devnull #undef _NEEDULONG
175 8ad51794 2004-03-25 devnull
176 1a0954ab 2005-01-04 devnull /*
177 1a0954ab 2005-01-04 devnull * Funny-named symbols to tip off 9l to autolink.
178 1a0954ab 2005-01-04 devnull */
179 1a0954ab 2005-01-04 devnull #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
180 58c52409 2005-10-29 devnull #define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1;
181 1a0954ab 2005-01-04 devnull
182 9b4de09d 2005-01-06 devnull /*
183 bc7da029 2005-05-07 devnull * Gcc is too smart for its own good.
184 9b4de09d 2005-01-06 devnull */
185 bc7da029 2005-05-07 devnull #if defined(__GNUC__)
186 c54b8b69 2006-01-27 devnull # undef strcmp /* causes way too many warnings */
187 bc7da029 2005-05-07 devnull # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
188 9b4de09d 2005-01-06 devnull # undef AUTOLIB
189 9b4de09d 2005-01-06 devnull # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
190 58c52409 2005-10-29 devnull # undef AUTOFRAMEWORK
191 58c52409 2005-10-29 devnull # define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak));
192 9d7a2e6e 2005-05-02 devnull # else
193 9d7a2e6e 2005-05-02 devnull # undef AUTOLIB
194 9d7a2e6e 2005-05-02 devnull # define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
195 58c52409 2005-10-29 devnull # undef AUTOFRAMEWORK
196 58c52409 2005-10-29 devnull # define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused));
197 9b4de09d 2005-01-06 devnull # endif
198 9b4de09d 2005-01-06 devnull #endif
199 9b4de09d 2005-01-06 devnull
200 8ad51794 2004-03-25 devnull #if defined(__cplusplus)
201 8ad51794 2004-03-25 devnull }
202 8ad51794 2004-03-25 devnull #endif
203 8ad51794 2004-03-25 devnull #endif