Blob


1 #ifndef _U_H_
2 #define _U_H_ 1
3 #if defined(__cplusplus)
4 extern "C" {
5 #endif
7 #define __BSD_VISIBLE 1 /* FreeBSD 5.x */
8 #define __EXTENSIONS__ 1 /* SunOS */
9 /* NOT USING #define __MAKECONTEXT_V2_SOURCE 1 / * SunOS */
10 #define _BSD_SOURCE 1
11 #define _NETBSD_SOURCE 1 /* NetBSD */
12 #define _SVID_SOURCE 1
13 #define _XOPEN_SOURCE 1000
14 #define _XOPEN_SOURCE_EXTENDED 1
15 #define _LARGEFILE64_SOURCE 1
16 #define _FILE_OFFSET_BITS 64
18 #include <unistd.h>
19 #include <string.h>
20 #include <stdlib.h>
21 #include <stdarg.h>
22 #include <fcntl.h>
23 #include <assert.h>
24 #include <setjmp.h>
25 #include <stddef.h>
26 #include <utf.h>
27 #include <fmt.h>
28 #include <math.h>
29 #include <ctype.h> /* for tolower */
31 /*
32 * OS-specific crap
33 */
34 #define _NEEDUCHAR 1
35 #define _NEEDUSHORT 1
36 #define _NEEDUINT 1
37 #define _NEEDULONG 1
39 typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
41 #if defined(__linux__)
42 # include <sys/types.h>
43 # if defined(__Linux26__)
44 # include <pthread.h>
45 # define PLAN9PORT_USING_PTHREADS 1
46 # endif
47 # if defined(__USE_MISC)
48 # undef _NEEDUSHORT
49 # undef _NEEDUINT
50 # undef _NEEDULONG
51 # endif
52 #elif defined(__sun__)
53 # include <sys/types.h>
54 # include <pthread.h>
55 # define PLAN9PORT_USING_PTHREADS 1
56 # undef _NEEDUSHORT
57 # undef _NEEDUINT
58 # undef _NEEDULONG
59 # define nil 0 /* no cast to void* */
60 #elif defined(__FreeBSD__)
61 # include <sys/types.h>
62 # include <osreldate.h>
63 # if __FreeBSD_version >= 500000
64 # define PLAN9PORT_USING_PTHREADS 1
65 # include <pthread.h>
66 # endif
67 # if !defined(_POSIX_SOURCE)
68 # undef _NEEDUSHORT
69 # undef _NEEDUINT
70 # endif
71 #elif defined(__APPLE__)
72 # include <sys/types.h>
73 # include <pthread.h>
74 # define PLAN9PORT_USING_PTHREADS 1
75 # if __GNUC__ < 4
76 # undef _NEEDUSHORT
77 # undef _NEEDUINT
78 # endif
79 # undef _ANSI_SOURCE
80 # undef _POSIX_C_SOURCE
81 # if !defined(NSIG)
82 # define NSIG 32
83 # endif
84 # define _NEEDLL 1
85 #elif defined(__NetBSD__)
86 # include <sched.h>
87 # include <sys/types.h>
88 # undef _NEEDUSHORT
89 # undef _NEEDUINT
90 # undef _NEEDULONG
91 #elif defined(__OpenBSD__)
92 # undef _NEEDUSHORT
93 # undef _NEEDUINT
94 # undef _NEEDULONG
95 #else
96 /* No idea what system this is -- try some defaults */
97 # include <pthread.h>
98 # define PLAN9PORT_USING_PTHREADS 1
99 #endif
101 #ifndef O_DIRECT
102 #define O_DIRECT 0
103 #endif
105 typedef signed char schar;
106 typedef unsigned int u32int;
107 typedef int s32int;
109 #ifdef _NEEDUCHAR
110 typedef unsigned char uchar;
111 #endif
112 #ifdef _NEEDUSHORT
113 typedef unsigned short ushort;
114 #endif
115 #ifdef _NEEDUINT
116 typedef unsigned int uint;
117 #endif
118 #ifdef _NEEDULONG
119 typedef unsigned long ulong;
120 #endif
121 typedef unsigned long long uvlong;
122 typedef long long vlong;
123 typedef uvlong u64int;
124 typedef vlong s64int;
125 typedef uchar u8int;
126 typedef schar s8int;
127 typedef ushort u16int;
128 typedef short s16int;
130 #undef _NEEDUCHAR
131 #undef _NEEDUSHORT
132 #undef _NEEDUINT
133 #undef _NEEDULONG
135 /*
136 * Funny-named symbols to tip off 9l to autolink.
137 */
138 #define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
140 /*
141 * Gcc is too smart for its own good.
142 */
143 #if defined(__GNUC__)
144 # if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__))
145 # undef AUTOLIB
146 # define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
147 # else
148 # undef AUTOLIB
149 # define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
150 # endif
151 #endif
153 #if defined(__cplusplus)
155 #endif
156 #endif