2
Plan 9 from User Space include/u.h
3
http://code.swtch.com/plan9port/src/tip/include/u.h
5
Copyright 2001-2007 Russ Cox. All Rights Reserved.
7
Permission is hereby granted, free of charge, to any person obtaining a copy
8
of this software and associated documentation files (the "Software"), to deal
9
in the Software without restriction, including without limitation the rights
10
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
copies of the Software, and to permit persons to whom the Software is
12
furnished to do so, subject to the following conditions:
14
The above copyright notice and this permission notice shall be included in
15
all copies or substantial portions of the Software.
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28
#if defined(__cplusplus)
32
#define __BSD_VISIBLE 1 /* FreeBSD 5.x */
34
# define __EXTENSIONS__ 1 /* SunOS */
35
# if defined(__SunOS5_6__) || defined(__SunOS5_7__) || defined(__SunOS5_8__)
36
/* NOT USING #define __MAKECONTEXT_V2_SOURCE 1 / * SunOS */
38
# define __MAKECONTEXT_V2_SOURCE 1
42
#define _NETBSD_SOURCE 1 /* NetBSD */
43
#define _SVID_SOURCE 1
44
#if !defined(__APPLE__) && !defined(__OpenBSD__)
45
# define _XOPEN_SOURCE 1000
46
# define _XOPEN_SOURCE_EXTENDED 1
48
#if defined(__FreeBSD__)
49
# include <sys/cdefs.h>
51
# undef __ISO_C_VISIBLE
52
# define __ISO_C_VISIBLE 1999
53
# undef __LONG_LONG_SUPPORTED
54
# define __LONG_LONG_SUPPORTED
56
#define _LARGEFILE64_SOURCE 1
57
#define _FILE_OFFSET_BITS 64
70
#include <ctype.h> /* for tolower */
83
typedef jmp_buf sigjmp_buf;
85
typedef long p9jmp_buf[sizeof(sigjmp_buf)/sizeof(long)];
87
#if defined(__linux__)
88
# include <sys/types.h>
89
# if defined(__Linux26__)
91
# define PLAN9PORT_USING_PTHREADS 1
93
# if defined(__USE_MISC)
98
#elif defined(__sun__)
99
# include <sys/types.h>
100
# include <pthread.h>
101
# define PLAN9PORT_USING_PTHREADS 1
105
# define nil 0 /* no cast to void* */
106
#elif defined(__FreeBSD__)
107
# include <sys/types.h>
108
# include <osreldate.h>
109
# if __FreeBSD_version >= 500000
110
# define PLAN9PORT_USING_PTHREADS 1
111
# include <pthread.h>
113
# if !defined(_POSIX_SOURCE)
117
#elif defined(__APPLE__)
118
# include <sys/types.h>
119
# include <pthread.h>
120
# define PLAN9PORT_USING_PTHREADS 1
126
# undef _POSIX_C_SOURCE
127
# undef _XOPEN_SOURCE
132
#elif defined(__NetBSD__)
134
# include <sys/types.h>
138
#elif defined(__OpenBSD__)
139
# include <sys/types.h>
143
#elif defined(_WIN32)
145
/* No idea what system this is -- try some defaults */
146
# include <pthread.h>
147
# define PLAN9PORT_USING_PTHREADS 1
154
typedef signed char schar;
157
typedef unsigned char uchar;
160
typedef unsigned short ushort;
163
typedef unsigned int uint;
166
typedef unsigned long ulong;
168
typedef unsigned long long uvlong;
169
typedef long long vlong;
171
typedef uint64_t u64int;
172
typedef int64_t s64int;
173
typedef uint8_t u8int;
174
typedef int8_t s8int;
175
typedef uint16_t u16int;
176
typedef int16_t s16int;
177
typedef uintptr_t uintptr;
178
typedef intptr_t intptr;
179
typedef uint32_t u32int;
180
typedef int32_t s32int;
184
typedef s16int int16;
185
typedef u16int uint16;
186
typedef s32int int32;
187
typedef u32int uint32;
188
typedef s64int int64;
189
typedef u64int uint64;
197
#define getcallerpc(x) __builtin_return_address(0)
200
#define SIGBUS SIGSEGV /* close enough */
204
* Funny-named symbols to tip off 9l to autolink.
206
#define AUTOLIB(x) static int __p9l_autolib_ ## x = 1;
207
#define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x = 1;
210
* Gcc is too smart for its own good.
212
#if defined(__GNUC__)
213
# undef strcmp /* causes way too many warnings */
214
# if __GNUC__ >= 4 || (__GNUC__==3 && !defined(__APPLE_CC__) && !defined(_WIN32))
216
# define AUTOLIB(x) int __p9l_autolib_ ## x __attribute__ ((weak));
217
# undef AUTOFRAMEWORK
218
# define AUTOFRAMEWORK(x) int __p9l_autoframework_ ## x __attribute__ ((weak));
221
# define AUTOLIB(x) static int __p9l_autolib_ ## x __attribute__ ((unused));
222
# undef AUTOFRAMEWORK
223
# define AUTOFRAMEWORK(x) static int __p9l_autoframework_ ## x __attribute__ ((unused));
227
#if defined(__cplusplus)