2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: compat.h /main/8 1996/07/18 16:32:14 drk $ */
25 * Copyright (c) 1991, 1993
26 * The Regents of the University of California. All rights reserved.
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
31 * 1. Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. All advertising materials mentioning features or use of this software
37 * must display the following acknowledgement:
38 * This product includes software developed by the University of
39 * California, Berkeley and its contributors.
40 * 4. Neither the name of the University nor the names of its contributors
41 * may be used to endorse or promote products derived from this software
42 * without specific prior written permission.
44 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
45 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
47 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
50 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
53 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * @(#)compat.h 8.3 (Berkeley) 9/6/93
62 #include <sys/types.h>
63 #include "utility/config.h"
66 * If your system doesn't typedef u_long, u_short, or u_char, change
70 typedef unsigned long u_long;
71 typedef unsigned short u_short;
72 typedef unsigned char u_char;
75 /* If your system doesn't typedef size_t, change the 0 to a 1. */
77 typedef unsigned int size_t;
81 * If your system doesn't have the POSIX type for a signal mask,
82 * change the 0 to a 1.
85 typedef unsigned int sigset_t;
89 * If your system's vsnprintf returns a char *, not an int,
90 * change the 0 to a 1.
92 #if !defined(_AIX) && !defined(__linux__) && !defined(CSRG_BASED) && !defined(sun)
93 #define VSPRINTF_CHARSTAR
97 * If you don't have POSIX 1003.1 signals, the signal code surrounding the
98 * temporary file creation is intended to block all of the possible signals
99 * long enough to create the file and unlink it. All of this stuff is
100 * intended to use old-style BSD calls to fake POSIX 1003.1 calls.
102 #ifdef NO_POSIX_SIGNALS
103 #define sigemptyset(set) (*(set) = 0)
104 #define sigfillset(set) (*(set) = ~(sigset_t)0, 0)
105 #define sigaddset(set,signo) (*(set) |= sigmask(signo), 0)
106 #define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0)
107 #define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0)
110 #define SIG_UNBLOCK 2
111 #define SIG_SETMASK 3
113 static int __sigtemp; /* For the use of sigprocmask */
115 /* Repeated test of oset != NULL is to avoid "*0". */
116 #define sigprocmask(how, set, oset) \
118 (((how) == SIG_BLOCK) ? \
119 sigblock(0) | *(set) : \
120 (((how) == SIG_UNBLOCK) ? \
121 sigblock(0) & ~(*(set)) : \
122 ((how) == SIG_SETMASK ? \
123 *(set) : sigblock(0))))), \
124 ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \
125 sigsetmask(__sigtemp)), 0)
129 * If realloc(3) of a NULL pointer on your system isn't the same as
130 * a malloc(3) call, change the 0 to a 1, and add realloc.o to the
131 * MISC line in your Makefile.
135 #define realloc __fix_realloc
138 void * __fix_realloc __P((void*, size_t));
142 * If your system doesn't have an include file with the appropriate
143 * byte order set, make sure you specify the correct one.
147 #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */
148 #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */
150 #ifdef MMDB_LITTLE_ENDIAN
151 #define BYTE_ORDER LITTLE_ENDIAN /* Set for your system. */
154 #ifdef MMDB_BIG_ENDIAN
155 #define BYTE_ORDER BIG_ENDIAN /* Set for your system. */
161 #if defined(SYSV) || defined(SYSTEM5) || defined(SVR4)
162 /* #define index(a, b) strchr(a, b) */
164 #define rindex(a, b) strrchr(a, b)
166 #define bzero(a, b) memset(a, 0, b)
167 #define bcmp(a, b, n) memcmp(a, b, n)
168 #define bcopy(a, b, n) memmove(b, a, n)
171 #if defined(BSD) || defined(BSD4_3)
172 #define strchr(a, b) index(a, b)
173 #define strrchr(a, b) rindex(a, b)
174 #define memcmp(a, b, n) bcmp(a, b, n)
175 #define memmove(a, b, n) bcopy(b, a, n)
179 * 32-bit machine. The db routines are theoretically independent of
180 * the size of u_shorts and u_longs, but I don't know that anyone has
181 * ever actually tried it. At a minimum, change the following #define's
182 * if you are trying to compile on a different type of system.
185 #define USHRT_MAX 0xFFFF
186 #define ULONG_MAX 0xFFFFFFFF
189 /* POSIX 1003.1 access mode mask. */
191 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
194 /* POSIX 1003.2 RE limit. */
195 #ifndef _POSIX2_RE_DUP_MAX
196 #define _POSIX2_RE_DUP_MAX 255
200 * If you can't provide lock values in the open(2) call. Note, this
201 * allows races to happen.
212 #define EFTYPE EINVAL /* POSIX 1003.1 format errno. */
215 #ifndef WCOREDUMP /* 4.4BSD extension */
216 #define WCOREDUMP(a) 0
219 #ifndef STDERR_FILENO
220 #define STDIN_FILENO 0 /* ANSI C #defines */
221 #define STDOUT_FILENO 1
222 #define STDERR_FILENO 2
226 #define SEEK_SET 0 /* POSIX 1003.1 seek values */
231 #ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */
232 #define S_ISLNK(m) ((m & 0170000) == 0120000)
233 #define S_ISSOCK(m) ((m & 0170000) == 0140000)
240 #ifndef _POSIX2_RE_DUP_MAX
241 #define _POSIX2_RE_DUP_MAX 255
244 #ifndef NULL /* ANSI C #defines NULL everywhere. */
249 #define MAX(a,b) ((a)<(b)?(b):(a))
252 #define MIN(a,b) ((a)<(b)?(a):(b))
254 #ifndef DEFFILEMODE /* Default file permissions. */
255 #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
258 #ifndef _BSD_VA_LIST_
259 #define _BSD_VA_LIST_ char *
262 #endif /* !_COMPAT_H_ */