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