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 #if !defined(__APPLE__) && !defined(__OpenBSD__)
23 # define _XOPEN_SOURCE 1000
24 # define _XOPEN_SOURCE_EXTENDED 1
26 #if defined(__FreeBSD__)
27 # include <sys/cdefs.h>
29 # undef __ISO_C_VISIBLE
30 # define __ISO_C_VISIBLE 1999
31 # undef __LONG_LONG_SUPPORTED
32 # define __LONG_LONG_SUPPORTED
35 # define _XOPEN_SOURCE 1
37 #if defined(__APPLE__)
38 # define _DARWIN_NO_64_BIT_INODE /* Snow Leopard */
40 #define _LARGEFILE64_SOURCE 1
41 #define _FILE_OFFSET_BITS 64
54 #include <ctype.h> /* for tolower */
64 typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
66 #if defined(__linux__)
67 # include <sys/types.h>
68 # if defined(__Linux26__)
70 # define PLAN9PORT_USING_PTHREADS 1
72 # if defined(__USE_MISC)
77 #elif defined(__sun__)
78 # include <sys/types.h>
80 # define PLAN9PORT_USING_PTHREADS 1
84 # define nil 0 /* no cast to void* */
85 #elif defined(__FreeBSD__)
86 # include <sys/types.h>
87 # include <osreldate.h>
88 # if __FreeBSD_version >= 500000
89 # define PLAN9PORT_USING_PTHREADS 1
92 # if !defined(_POSIX_SOURCE)
96 #elif defined(__APPLE__)
97 # include <sys/types.h>
99 # define PLAN9PORT_USING_PTHREADS 1
105 # undef _POSIX_C_SOURCE
106 # undef _XOPEN_SOURCE
111 #elif defined(__NetBSD__)
113 # include <sys/types.h>
117 #elif defined(__OpenBSD__)
118 # include <sys/types.h>
123 /* No idea what system this is -- try some defaults */
124 # include <pthread.h>
125 # define PLAN9PORT_USING_PTHREADS 1
132 typedef signed char schar;
135 typedef unsigned char uchar;
138 typedef unsigned short ushort;
141 typedef unsigned int uint;
144 typedef unsigned long ulong;
146 typedef unsigned long long uvlong;
147 typedef long long vlong;
149 typedef uvlong u64int;
150 typedef vlong s64int;
151 typedef uint8_t u8int;
152 typedef int8_t s8int;
153 typedef uint16_t u16int;
154 typedef int16_t s16int;
155 typedef uintptr_t uintptr;
156 typedef intptr_t intptr;
160 typedef u32int uint32;
161 typedef s32int int32;
162 typedef u16int uint16;
163 typedef s16int int16;
164 typedef u64int uint64;
165 typedef s64int int64;
175 * Funny-named symbols to tip off 9l to autolink.
177 #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
178 #define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1;
181 * Gcc is too smart for its own good.
183 #if defined(__GNUC__)
184 # undef strcmp /* causes way too many warnings */
185 # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
187 # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
188 # undef AUTOFRAMEWORK
189 # define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak));
192 # define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
193 # undef AUTOFRAMEWORK
194 # define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused));
198 #if defined(__cplusplus)