andre@3: /*- andre@3: * Copyright (c) 1991, 1993 andre@3: * The Regents of the University of California. All rights reserved. andre@3: * andre@3: * Redistribution and use in source and binary forms, with or without andre@3: * modification, are permitted provided that the following conditions andre@3: * are met: andre@3: * 1. Redistributions of source code must retain the above copyright andre@3: * notice, this list of conditions and the following disclaimer. andre@3: * 2. Redistributions in binary form must reproduce the above copyright andre@3: * notice, this list of conditions and the following disclaimer in the andre@3: * documentation and/or other materials provided with the distribution. andre@3: * 3. ***REMOVED*** - see andre@3: * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change andre@3: * 4. Neither the name of the University nor the names of its contributors andre@3: * may be used to endorse or promote products derived from this software andre@3: * without specific prior written permission. andre@3: * andre@3: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND andre@3: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE andre@3: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE andre@3: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE andre@3: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL andre@3: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS andre@3: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) andre@3: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT andre@3: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY andre@3: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF andre@3: * SUCH DAMAGE. andre@3: * andre@3: * @(#)compat.h 8.13 (Berkeley) 2/21/94 andre@3: */ andre@3: andre@3: #ifndef _COMPAT_H_ andre@3: #define _COMPAT_H_ andre@3: andre@3: #include andre@3: andre@3: /* andre@3: * If your system doesn't typedef u_long, u_short, or u_char, change andre@3: * the 0 to a 1. andre@3: */ andre@3: #if 0 andre@3: typedef unsigned char u_char; /* 4.[34]BSD names. */ andre@3: typedef unsigned int u_int; andre@3: typedef unsigned long u_long; andre@3: typedef unsigned short u_short; andre@3: #endif andre@3: andre@3: /* If your system doesn't typedef size_t, change the 0 to a 1. */ andre@3: #if 0 andre@3: typedef unsigned int size_t; /* POSIX, 4.[34]BSD names. */ andre@3: #endif andre@3: andre@3: /* If your system doesn't typedef ssize_t, change the 0 to a 1. */ andre@3: #if 0 andre@3: typedef int ssize_t; /* POSIX names. */ andre@3: #endif andre@3: andre@3: /* andre@3: * If your system doesn't have the POSIX type for a signal mask, andre@3: * change the 0 to a 1. andre@3: */ andre@3: #if 0 /* POSIX 1003.1 signal mask type. */ andre@3: typedef unsigned int sigset_t; andre@3: #endif andre@3: andre@3: /* andre@3: * If your system's vsprintf returns a char *, not an int, andre@3: * change the 0 to a 1. andre@3: */ andre@3: #if defined (__sun) && !defined(__SVR4) /* SUNOS */ andre@3: #define VSPRINTF_CHARSTAR andre@3: #endif andre@3: /* andre@3: * If you don't have POSIX 1003.1 signals, the signal code surrounding the andre@3: * temporary file creation is intended to block all of the possible signals andre@3: * long enough to create the file and unlink it. All of this stuff is andre@3: * intended to use old-style BSD calls to fake POSIX 1003.1 calls. andre@3: */ andre@3: #ifdef NO_POSIX_SIGNALS andre@3: #define sigemptyset(set) (*(set) = 0) andre@3: #define sigfillset(set) (*(set) = ~(sigset_t)0, 0) andre@3: #define sigaddset(set,signo) (*(set) |= sigmask(signo), 0) andre@3: #define sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0) andre@3: #define sigismember(set,signo) ((*(set) & sigmask(signo)) != 0) andre@3: andre@3: #define SIG_BLOCK 1 andre@3: #define SIG_UNBLOCK 2 andre@3: #define SIG_SETMASK 3 andre@3: andre@3: static int __sigtemp; /* For the use of sigprocmask */ andre@3: andre@3: /* Repeated test of oset != NULL is to avoid "*0". */ andre@3: #define sigprocmask(how, set, oset) \ andre@3: ((__sigtemp = \ andre@3: (((how) == SIG_BLOCK) ? \ andre@3: sigblock(0) | *(set) : \ andre@3: (((how) == SIG_UNBLOCK) ? \ andre@3: sigblock(0) & ~(*(set)) : \ andre@3: ((how) == SIG_SETMASK ? \ andre@3: *(set) : sigblock(0))))), \ andre@3: ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) : \ andre@3: sigsetmask(__sigtemp)), 0) andre@3: #endif andre@3: andre@3: /* andre@3: * If your system doesn't have an include file with the appropriate andre@3: * byte order set, make sure you specify the correct one. andre@3: */ andre@3: #ifndef BYTE_ORDER andre@3: #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ andre@3: #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ andre@3: #define BYTE_ORDER BIG_ENDIAN /* Set for your system. */ andre@3: #endif andre@3: andre@3: #if defined(SYSV) || defined(SYSTEM5) || defined(__sun) andre@3: #define index(a, b) strchr(a, b) andre@3: #define rindex(a, b) strrchr(a, b) andre@3: #define bzero(a, b) memset(a, 0, b) andre@3: #define bcmp(a, b, n) memcmp(a, b, n) andre@3: #define bcopy(a, b, n) memmove(b, a, n) andre@3: #endif andre@3: andre@3: #if defined(BSD) || defined(BSD4_3) andre@3: #define strchr(a, b) index(a, b) andre@3: #define strrchr(a, b) rindex(a, b) andre@3: #define memcmp(a, b, n) bcmp(a, b, n) andre@3: #define memmove(a, b, n) bcopy(b, a, n) andre@3: #endif andre@3: andre@3: /* andre@3: * 32-bit machine. The db routines are theoretically independent of andre@3: * the size of u_shorts and u_longs, but I don't know that anyone has andre@3: * ever actually tried it. At a minimum, change the following #define's andre@3: * if you are trying to compile on a different type of system. andre@3: */ andre@3: #ifndef USHRT_MAX andre@3: #define USHRT_MAX 0xFFFF andre@3: #define ULONG_MAX 0xFFFFFFFF andre@3: #endif andre@3: andre@3: #ifndef O_ACCMODE /* POSIX 1003.1 access mode mask. */ andre@3: #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) andre@3: #endif andre@3: andre@3: #ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 RE limit. */ andre@3: #define _POSIX2_RE_DUP_MAX 255 andre@3: #endif andre@3: andre@3: /* andre@3: * If you can't provide lock values in the open(2) call. Note, this andre@3: * allows races to happen. andre@3: */ andre@3: #ifndef O_EXLOCK /* 4.4BSD extension. */ andre@3: #define O_EXLOCK 0 andre@3: #endif andre@3: andre@3: #ifndef O_SHLOCK /* 4.4BSD extension. */ andre@3: #define O_SHLOCK 0 andre@3: #endif andre@3: andre@3: #ifndef EFTYPE andre@3: #define EFTYPE EINVAL /* POSIX 1003.1 format errno. */ andre@3: #endif andre@3: andre@3: #ifndef WCOREDUMP /* 4.4BSD extension */ andre@3: #define WCOREDUMP(a) 0 andre@3: #endif andre@3: andre@3: #ifndef STDERR_FILENO andre@3: #define STDIN_FILENO 0 /* ANSI C #defines */ andre@3: #define STDOUT_FILENO 1 andre@3: #define STDERR_FILENO 2 andre@3: #endif andre@3: andre@3: #ifndef SEEK_END andre@3: #define SEEK_SET 0 /* POSIX 1003.1 seek values */ andre@3: #define SEEK_CUR 1 andre@3: #define SEEK_END 2 andre@3: #endif andre@3: andre@3: #ifndef _POSIX_VDISABLE /* POSIX 1003.1 disabling char. */ andre@3: #define _POSIX_VDISABLE 0 /* Some systems used 0. */ andre@3: #endif andre@3: andre@3: #ifndef TCSASOFT /* 4.4BSD extension. */ andre@3: #define TCSASOFT 0 andre@3: #endif andre@3: andre@3: #ifndef _POSIX2_RE_DUP_MAX /* POSIX 1003.2 values. */ andre@3: #define _POSIX2_RE_DUP_MAX 255 andre@3: #endif andre@3: andre@3: #ifndef NULL /* ANSI C #defines NULL everywhere. */ andre@3: #define NULL 0 andre@3: #endif andre@3: andre@3: #ifndef MAX /* Usually found in . */ andre@3: #define MAX(_a,_b) ((_a)<(_b)?(_b):(_a)) andre@3: #endif andre@3: #ifndef MIN /* Usually found in . */ andre@3: #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b)) andre@3: #endif andre@3: andre@3: /* Default file permissions. */ andre@3: #ifndef DEFFILEMODE /* 4.4BSD extension. */ andre@3: #define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) andre@3: #endif andre@3: andre@3: #ifndef __sun andre@3: #ifndef S_ISDIR /* POSIX 1003.1 file type tests. */ andre@3: #define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */ andre@3: #define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */ andre@3: #define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */ andre@3: #define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */ andre@3: #define S_ISFIFO(m) ((m & 0170000) == 0010000) /* fifo */ andre@3: #endif andre@3: #ifndef S_ISLNK /* BSD POSIX 1003.1 extensions */ andre@3: #define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */ andre@3: #define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ andre@3: #endif andre@3: #endif /* __sun */ andre@3: andre@3: /* The type of a va_list. */ andre@3: #ifndef _BSD_VA_LIST_ /* 4.4BSD #define. */ andre@3: #define _BSD_VA_LIST_ char * andre@3: #endif andre@3: andre@3: #endif /* !_COMPAT_H_ */