1 // See ../src/lib9/LICENSE
5 #if defined(__cplusplus)
9 #define __BSD_VISIBLE 1 /* FreeBSD 5.x */
11 # define __EXTENSIONS__ 1 /* SunOS */
12 # if defined(__SunOS5_6__) || defined(__SunOS5_7__) || defined(__SunOS5_8__) || defined(__SunOS5_9__) || defined(__SunOS5_10__)
13 /* NOT USING #define __MAKECONTEXT_V2_SOURCE 1 / * SunOS */
16 # define __MAKECONTEXT_V2_SOURCE 1
20 #define _NETBSD_SOURCE 1 /* NetBSD */
21 #define _SVID_SOURCE 1
22 #define _DEFAULT_SOURCE 1
23 #if !defined(__APPLE__) && !defined(__OpenBSD__)
24 # define _XOPEN_SOURCE 1000
25 # define _XOPEN_SOURCE_EXTENDED 1
27 #if defined(__FreeBSD__)
28 # include <sys/cdefs.h>
30 # undef __ISO_C_VISIBLE
31 # define __ISO_C_VISIBLE 1999
32 # undef __LONG_LONG_SUPPORTED
33 # define __LONG_LONG_SUPPORTED
36 # define _XOPEN_SOURCE 1
38 #if defined(__APPLE__)
39 # define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */
41 #define _LARGEFILE64_SOURCE 1
42 #define _FILE_OFFSET_BITS 64
55 #include <ctype.h> /* for tolower */
65 typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
67 #if defined(__linux__)
68 # include <sys/types.h>
69 # if defined(__Linux26__)
71 # define PLAN9PORT_USING_PTHREADS 1
73 # if defined(__USE_MISC)
78 #elif defined(__sun__)
79 # include <sys/types.h>
81 # define PLAN9PORT_USING_PTHREADS 1
85 # define nil 0 /* no cast to void* */
86 #elif defined(__FreeBSD__)
87 # include <sys/types.h>
88 # include <osreldate.h>
89 # if __FreeBSD_version >= 500000
90 # define PLAN9PORT_USING_PTHREADS 1
93 # if !defined(_POSIX_SOURCE)
97 #elif defined(__APPLE__)
98 # include <sys/types.h>
100 # define PLAN9PORT_USING_PTHREADS 1
106 # undef _POSIX_C_SOURCE
107 # undef _XOPEN_SOURCE
112 #elif defined(__NetBSD__)
114 # include <sys/types.h>
118 #elif defined(__OpenBSD__)
119 # include <sys/types.h>
120 # include <pthread.h>
121 # define PLAN9PORT_USING_PTHREADS 1
126 /* No idea what system this is -- try some defaults */
127 # include <pthread.h>
128 # define PLAN9PORT_USING_PTHREADS 1
135 typedef signed char schar;
138 typedef unsigned char uchar;
141 typedef unsigned short ushort;
144 typedef unsigned int uint;
147 typedef unsigned long ulong;
149 typedef unsigned long long uvlong;
150 typedef long long vlong;
152 typedef uvlong u64int;
153 typedef vlong s64int;
154 typedef uint8_t u8int;
155 typedef int8_t s8int;
156 typedef uint16_t u16int;
157 typedef int16_t s16int;
158 typedef uintptr_t uintptr;
159 typedef intptr_t intptr;
163 typedef u32int uint32;
164 typedef s32int int32;
165 typedef u16int uint16;
166 typedef s16int int16;
167 typedef u64int uint64;
168 typedef s64int int64;
178 * Funny-named symbols to tip off 9l to autolink.
180 #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
181 #define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1;
184 * Gcc is too smart for its own good.
186 #if defined(__GNUC__)
187 # undef strcmp /* causes way too many warnings */
188 # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
190 # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
191 # undef AUTOFRAMEWORK
192 # define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak));
195 # define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
196 # undef AUTOFRAMEWORK
197 # define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused));
201 #if defined(__cplusplus)