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