Back to index

lightning-sunbird  0.9+nobinonly
ncompat.h
Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1991, 1993
00003  *     The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. ***REMOVED*** - see 
00014  *    ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
00015  * 4. Neither the name of the University nor the names of its contributors
00016  *    may be used to endorse or promote products derived from this software
00017  *    without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00020  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00023  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00024  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00025  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00026  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00028  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00029  * SUCH DAMAGE.
00030  *
00031  *     @(#)compat.h  8.13 (Berkeley) 2/21/94
00032  */
00033 
00034 #ifndef       _COMPAT_H_
00035 #define       _COMPAT_H_
00036 
00037 #include <sys/types.h>
00038 
00039 /*
00040  * If your system doesn't typedef u_long, u_short, or u_char, change
00041  * the 0 to a 1.
00042  */
00043 #if 0
00044 typedef unsigned char       u_char;              /* 4.[34]BSD names. */
00045 typedef unsigned int u_int;
00046 typedef unsigned long       u_long;
00047 typedef unsigned short      u_short;
00048 #endif
00049 
00050 /* If your system doesn't typedef size_t, change the 0 to a 1. */
00051 #if 0
00052 typedef unsigned int size_t;              /* POSIX, 4.[34]BSD names. */
00053 #endif
00054 
00055 /* If your system doesn't typedef ssize_t, change the 0 to a 1. */
00056 #if 0
00057 typedef       int           ssize_t;      /* POSIX names. */
00058 #endif
00059 
00060 /*
00061  * If your system doesn't have the POSIX type for a signal mask,
00062  * change the 0 to a 1.
00063  */
00064 #if 0                              /* POSIX 1003.1 signal mask type. */
00065 typedef unsigned int sigset_t;
00066 #endif
00067 
00068 /*
00069  * If your system's vsprintf returns a char *, not an int,
00070  * change the 0 to a 1.
00071  */
00072 #if defined (__sun) && !defined(__SVR4) /* SUNOS */
00073 #define       VSPRINTF_CHARSTAR
00074 #endif
00075 /*
00076  * If you don't have POSIX 1003.1 signals, the signal code surrounding the 
00077  * temporary file creation is intended to block all of the possible signals
00078  * long enough to create the file and unlink it.  All of this stuff is
00079  * intended to use old-style BSD calls to fake POSIX 1003.1 calls.
00080  */
00081 #ifdef NO_POSIX_SIGNALS
00082 #define       sigemptyset(set)     (*(set) = 0)
00083 #define       sigfillset(set)             (*(set) = ~(sigset_t)0, 0)
00084 #define       sigaddset(set,signo) (*(set) |= sigmask(signo), 0)
00085 #define       sigdelset(set,signo) (*(set) &= ~sigmask(signo), 0)
00086 #define       sigismember(set,signo)      ((*(set) & sigmask(signo)) != 0)
00087 
00088 #define       SIG_BLOCK     1
00089 #define       SIG_UNBLOCK   2
00090 #define       SIG_SETMASK   3
00091 
00092 static int __sigtemp;              /* For the use of sigprocmask */
00093 
00094 /* Repeated test of oset != NULL is to avoid "*0". */
00095 #define       sigprocmask(how, set, oset)                             \
00096        ((__sigtemp =                                           \
00097        (((how) == SIG_BLOCK) ?                                        \
00098               sigblock(0) | *(set) :                                  \
00099        (((how) == SIG_UNBLOCK) ?                               \
00100               sigblock(0) & ~(*(set)) :                        \
00101        ((how) == SIG_SETMASK ?                                        \
00102               *(set) : sigblock(0))))),                        \
00103        ((oset) ? (*(oset ? oset : set) = sigsetmask(__sigtemp)) :     \
00104               sigsetmask(__sigtemp)), 0)
00105 #endif
00106 
00107 /*
00108  * If your system doesn't have an include file with the appropriate
00109  * byte order set, make sure you specify the correct one.
00110  */
00111 #ifndef BYTE_ORDER
00112 #define       LITTLE_ENDIAN 1234          /* LSB first: i386, vax */
00113 #define       BIG_ENDIAN    4321          /* MSB first: 68000, ibm, net */
00114 #define       BYTE_ORDER    BIG_ENDIAN    /* Set for your system. */
00115 #endif
00116 
00117 #if defined(SYSV) || defined(SYSTEM5) || defined(__sun)
00118 #define       index(a, b)          strchr(a, b)
00119 #define       rindex(a, b)         strrchr(a, b)
00120 #define       bzero(a, b)          memset(a, 0, b)
00121 #define       bcmp(a, b, n)        memcmp(a, b, n)
00122 #define       bcopy(a, b, n)              memmove(b, a, n)
00123 #endif
00124 
00125 #if defined(BSD) || defined(BSD4_3)
00126 #define       strchr(a, b)         index(a, b)
00127 #define       strrchr(a, b)        rindex(a, b)
00128 #define       memcmp(a, b, n)             bcmp(a, b, n)
00129 #define       memmove(a, b, n)     bcopy(b, a, n)
00130 #endif
00131 
00132 /*
00133  * 32-bit machine.  The db routines are theoretically independent of
00134  * the size of u_shorts and u_longs, but I don't know that anyone has
00135  * ever actually tried it.  At a minimum, change the following #define's
00136  * if you are trying to compile on a different type of system.
00137  */
00138 #ifndef USHRT_MAX
00139 #define       USHRT_MAX            0xFFFF
00140 #define       ULONG_MAX            0xFFFFFFFF
00141 #endif
00142 
00143 #ifndef O_ACCMODE                  /* POSIX 1003.1 access mode mask. */
00144 #define       O_ACCMODE     (O_RDONLY|O_WRONLY|O_RDWR)
00145 #endif
00146 
00147 #ifndef       _POSIX2_RE_DUP_MAX          /* POSIX 1003.2 RE limit. */
00148 #define       _POSIX2_RE_DUP_MAX   255
00149 #endif
00150 
00151 /*
00152  * If you can't provide lock values in the open(2) call.  Note, this
00153  * allows races to happen.
00154  */
00155 #ifndef O_EXLOCK                   /* 4.4BSD extension. */
00156 #define       O_EXLOCK      0
00157 #endif
00158 
00159 #ifndef O_SHLOCK                   /* 4.4BSD extension. */
00160 #define       O_SHLOCK      0
00161 #endif
00162 
00163 #ifndef EFTYPE
00164 #define       EFTYPE        EINVAL        /* POSIX 1003.1 format errno. */
00165 #endif
00166 
00167 #ifndef       WCOREDUMP                   /* 4.4BSD extension */
00168 #define       WCOREDUMP(a)  0
00169 #endif
00170 
00171 #ifndef       STDERR_FILENO
00172 #define       STDIN_FILENO  0             /* ANSI C #defines */
00173 #define       STDOUT_FILENO 1
00174 #define       STDERR_FILENO 2
00175 #endif
00176 
00177 #ifndef SEEK_END
00178 #define       SEEK_SET      0             /* POSIX 1003.1 seek values */
00179 #define       SEEK_CUR      1
00180 #define       SEEK_END      2
00181 #endif
00182 
00183 #ifndef _POSIX_VDISABLE                   /* POSIX 1003.1 disabling char. */
00184 #define       _POSIX_VDISABLE      0             /* Some systems used 0. */
00185 #endif
00186 
00187 #ifndef       TCSASOFT                    /* 4.4BSD extension. */
00188 #define       TCSASOFT      0
00189 #endif
00190 
00191 #ifndef _POSIX2_RE_DUP_MAX         /* POSIX 1003.2 values. */
00192 #define       _POSIX2_RE_DUP_MAX   255
00193 #endif
00194 
00195 #ifndef NULL                       /* ANSI C #defines NULL everywhere. */
00196 #define       NULL          0
00197 #endif
00198 
00199 #ifndef       MAX                         /* Usually found in <sys/param.h>. */
00200 #define       MAX(_a,_b)    ((_a)<(_b)?(_b):(_a))
00201 #endif
00202 #ifndef       MIN                         /* Usually found in <sys/param.h>. */
00203 #define       MIN(_a,_b)    ((_a)<(_b)?(_a):(_b))
00204 #endif
00205 
00206 /* Default file permissions. */
00207 #ifndef DEFFILEMODE                /* 4.4BSD extension. */
00208 #define       DEFFILEMODE   (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
00209 #endif
00210 
00211 #ifndef __sun
00212 #ifndef S_ISDIR                           /* POSIX 1003.1 file type tests. */
00213 #define       S_ISDIR(m)    ((m & 0170000) == 0040000)  /* directory */
00214 #define       S_ISCHR(m)    ((m & 0170000) == 0020000)  /* char special */
00215 #define       S_ISBLK(m)    ((m & 0170000) == 0060000)  /* block special */
00216 #define       S_ISREG(m)    ((m & 0170000) == 0100000)  /* regular file */
00217 #define       S_ISFIFO(m)   ((m & 0170000) == 0010000)  /* fifo */
00218 #endif
00219 #ifndef S_ISLNK                           /* BSD POSIX 1003.1 extensions */
00220 #define       S_ISLNK(m)    ((m & 0170000) == 0120000)  /* symbolic link */
00221 #define       S_ISSOCK(m)   ((m & 0170000) == 0140000)  /* socket */
00222 #endif
00223 #endif /* __sun */
00224 
00225 /* The type of a va_list. */
00226 #ifndef _BSD_VA_LIST_                     /* 4.4BSD #define. */
00227 #define       _BSD_VA_LIST_ char *
00228 #endif
00229 
00230 #endif /* !_COMPAT_H_ */