Commit | Line | Data |
---|---|---|
ad787160 C |
1 | /*- |
2 | * Copyright (c) 1991, 1993 | |
3 | * The Regents of the University of California. All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * 1. Redistributions of source code must retain the above copyright | |
9 | * notice, this list of conditions and the following disclaimer. | |
10 | * 2. Redistributions in binary form must reproduce the above copyright | |
11 | * notice, this list of conditions and the following disclaimer in the | |
12 | * documentation and/or other materials provided with the distribution. | |
13 | * 3. All advertising materials mentioning features or use of this software | |
14 | * must display the following acknowledgement: | |
15 | * This product includes software developed by the University of | |
16 | * California, Berkeley and its contributors. | |
17 | * 4. Neither the name of the University nor the names of its contributors | |
18 | * may be used to endorse or promote products derived from this software | |
19 | * without specific prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
31 | * SUCH DAMAGE. | |
32 | * | |
fd88f5c5 | 33 | * @(#)compat.h 8.18 (Berkeley) 6/28/94 |
ad787160 C |
34 | */ |
35 | ||
36 | #ifndef _COMPAT_H_ | |
37 | #define _COMPAT_H_ | |
38 | ||
ed554bc5 C |
39 | #include <sys/types.h> |
40 | ||
ad787160 C |
41 | /* |
42 | * If your system doesn't typedef u_long, u_short, or u_char, change | |
43 | * the 0 to a 1. | |
44 | */ | |
45 | #if 0 | |
ed554bc5 C |
46 | typedef unsigned char u_char; /* 4.[34]BSD names. */ |
47 | typedef unsigned int u_int; | |
ad787160 C |
48 | typedef unsigned long u_long; |
49 | typedef unsigned short u_short; | |
ad787160 C |
50 | #endif |
51 | ||
52 | /* If your system doesn't typedef size_t, change the 0 to a 1. */ | |
53 | #if 0 | |
ed554bc5 C |
54 | typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ |
55 | #endif | |
56 | ||
57 | /* If your system doesn't typedef ssize_t, change the 0 to a 1. */ | |
58 | #if 0 | |
59 | typedef int ssize_t; /* POSIX names. */ | |
ad787160 C |
60 | #endif |
61 | ||
fd88f5c5 C |
62 | /* Modify these typedef's as necessary. */ |
63 | #ifndef __BIT_TYPES_DEFINED__ | |
64 | #define __BIT_TYPES_DEFINED__ | |
ed554bc5 C |
65 | typedef char int8_t; |
66 | typedef unsigned char u_int8_t; | |
67 | typedef short int16_t; | |
68 | typedef unsigned short u_int16_t; | |
69 | typedef int int32_t; | |
70 | typedef unsigned int u_int32_t; | |
71 | #ifdef WE_DONT_NEED_QUADS | |
72 | typedef long long int64_t; | |
73 | typedef unsigned long long u_int64_t; | |
74 | #endif | |
ad787160 C |
75 | #endif |
76 | ||
77 | /* | |
78 | * If your system doesn't have the POSIX type for a signal mask, | |
79 | * change the 0 to a 1. | |
80 | */ | |
ed554bc5 | 81 | #if 0 /* POSIX 1003.1 signal mask type. */ |
ad787160 C |
82 | typedef unsigned int sigset_t; |
83 | #endif | |
84 | ||
85 | /* | |
86 | * If your system's vsprintf returns a char *, not an int, | |
87 | * change the 0 to a 1. | |
88 | */ | |
89 | #if 0 | |
90 | #define VSPRINTF_CHARSTAR | |
91 | #endif | |
92 | ||
93 | /* | |
94 | * If you don't have POSIX 1003.1 signals, the signal code surrounding the | |
95 | * temporary file creation is intended to block all of the possible signals | |
96 | * long enough to create the file and unlink it. All of this stuff is | |
97 | * intended to use old-style BSD calls to fake POSIX 1003.1 calls. | |
98 | */ | |
ed554bc5 C |
99 | #ifdef NO_POSIX_SIGNALS |
100 | #define sigemptyset(set) (*(set) = 0) | |
101 | #define sigfillset(set) (*(set) = ~(sigset_t)0, 0) | |
102 | #define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) | |
103 | #define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) | |
104 | #define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) | |
ad787160 | 105 | |
ed554bc5 C |
106 | #define SIG_BLOCK 1 |
107 | #define SIG_UNBLOCK 2 | |
108 | #define SIG_SETMASK 3 | |
ad787160 C |
109 | |
110 | static int __sigtemp; /* For the use of sigprocmask */ | |
111 | ||
ed554bc5 C |
112 | /* Repeated test of oset != NULL is to avoid "*0". */ |
113 | #define sigprocmask(how, set, oset) \ | |
114 | ((__sigtemp = \ | |
115 | (((how) == SIG_BLOCK) ? \ | |
116 | sigblock(0) | *(set) : \ | |
117 | (((how) == SIG_UNBLOCK) ? \ | |
118 | sigblock(0) & ~(*(set)) : \ | |
119 | ((how) == SIG_SETMASK ? \ | |
120 | *(set) : sigblock(0))))), \ | |
121 | ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ | |
122 | sigsetmask(__sigtemp)), 0) | |
ad787160 C |
123 | #endif |
124 | ||
ad787160 C |
125 | /* |
126 | * If your system doesn't have an include file with the appropriate | |
127 | * byte order set, make sure you specify the correct one. | |
128 | */ | |
129 | #ifndef BYTE_ORDER | |
ed554bc5 C |
130 | #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ |
131 | #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ | |
132 | #define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */ | |
ad787160 C |
133 | #endif |
134 | ||
135 | #if defined(SYSV) || defined(SYSTEM5) | |
136 | #define index(a, b) strchr(a, b) | |
137 | #define rindex(a, b) strrchr(a, b) | |
138 | #define bzero(a, b) memset(a, 0, b) | |
139 | #define bcmp(a, b, n) memcmp(a, b, n) | |
140 | #define bcopy(a, b, n) memmove(b, a, n) | |
141 | #endif | |
142 | ||
143 | #if defined(BSD) || defined(BSD4_3) | |
144 | #define strchr(a, b) index(a, b) | |
145 | #define strrchr(a, b) rindex(a, b) | |
146 | #define memcmp(a, b, n) bcmp(a, b, n) | |
147 | #define memmove(a, b, n) bcopy(b, a, n) | |
148 | #endif | |
149 | ||
150 | /* | |
151 | * 32-bit machine. The db routines are theoretically independent of | |
152 | * the size of u_shorts and u_longs, but I don't know that anyone has | |
153 | * ever actually tried it. At a minimum, change the following #define's | |
154 | * if you are trying to compile on a different type of system. | |
155 | */ | |
156 | #ifndef USHRT_MAX | |
157 | #define USHRT_MAX 0xFFFF | |
158 | #define ULONG_MAX 0xFFFFFFFF | |
159 | #endif | |
160 | ||
ed554bc5 | 161 | #ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ |
ad787160 C |
162 | #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) |
163 | #endif | |
164 | ||
ed554bc5 | 165 | #ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ |
ad787160 C |
166 | #define _POSIX2_RE_DUP_MAX 255 |
167 | #endif | |
168 | ||
169 | /* | |
170 | * If you can't provide lock values in the open(2) call. Note, this | |
171 | * allows races to happen. | |
172 | */ | |
ed554bc5 | 173 | #ifndef O_EXLOCK /* 4.4BSD extension. */ |
ad787160 C |
174 | #define O_EXLOCK 0 |
175 | #endif | |
176 | ||
ed554bc5 | 177 | #ifndef O_SHLOCK /* 4.4BSD extension. */ |
ad787160 C |
178 | #define O_SHLOCK 0 |
179 | #endif | |
180 | ||
181 | #ifndef EFTYPE | |
182 | #define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ | |
183 | #endif | |
184 | ||
185 | #ifndef WCOREDUMP /* 4.4BSD extension */ | |
186 | #define WCOREDUMP(a) 0 | |
187 | #endif | |
188 | ||
189 | #ifndef STDERR_FILENO | |
190 | #define STDIN_FILENO 0 /* ANSI C #defines */ | |
191 | #define STDOUT_FILENO 1 | |
192 | #define STDERR_FILENO 2 | |
193 | #endif | |
194 | ||
195 | #ifndef SEEK_END | |
196 | #define SEEK_SET 0 /* POSIX 1003.1 seek values */ | |
197 | #define SEEK_CUR 1 | |
198 | #define SEEK_END 2 | |
199 | #endif | |
200 | ||
ed554bc5 C |
201 | #ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ |
202 | #define _POSIX_VDISABLE 0 /* Some systems used 0. */ | |
203 | #endif | |
204 | ||
205 | #ifndef TCSASOFT /* 4.4BSD extension. */ | |
206 | #define TCSASOFT 0 | |
ad787160 C |
207 | #endif |
208 | ||
ed554bc5 | 209 | #ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ |
ad787160 C |
210 | #define _POSIX2_RE_DUP_MAX 255 |
211 | #endif | |
212 | ||
213 | #ifndef NULL /* ANSI C #defines NULL everywhere. */ | |
214 | #define NULL 0 | |
215 | #endif | |
216 | ||
ed554bc5 | 217 | #ifndef MAX /* Usually found in <sys/param.h>. */ |
ad787160 C |
218 | #define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) |
219 | #endif | |
ed554bc5 | 220 | #ifndef MIN /* Usually found in <sys/param.h>. */ |
ad787160 C |
221 | #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) |
222 | #endif | |
223 | ||
ed554bc5 C |
224 | /* Default file permissions. */ |
225 | #ifndef DEFFILEMODE /* 4.4BSD extension. */ | |
226 | #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) | |
227 | #endif | |
228 | ||
229 | #ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ | |
230 | #define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ | |
231 | #define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ | |
232 | #define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ | |
233 | #define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ | |
234 | #define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ | |
235 | #endif | |
236 | #ifndef S_ISLNK /* BSD POSIX 1003.1 extension */ | |
237 | #define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ | |
238 | #endif | |
239 | #ifndef S_ISSOCK /* BSD POSIX 1003.1 extension */ | |
240 | #define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket, pipe */ | |
241 | #endif | |
242 | ||
243 | /* The type of a va_list. */ | |
244 | #ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ | |
ad787160 C |
245 | #define _BSD_VA_LIST_ char * |
246 | #endif | |
247 | ||
248 | #endif /* !_COMPAT_H_ */ |