tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ncompat.h (7522B)


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