home *** CD-ROM | disk | FTP | other *** search
/ Super Net 1 / SUPERNET_1.iso / PC / OTROS / EXTRAS / UUCODE / UUPC / TEST / UPC12ES4.ZIP / UUTRAF / sysdefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-16  |  9.9 KB  |  364 lines

  1. /*
  2.  *    sysdefs.h - Configuration options header file.
  3.  */
  4.  
  5. #define SID_H    "@(#)head:sysdefs.h    1.3    92/10/03 20:34:24 (woods)"
  6. #define SID_NM    sysdefs_sccsid
  7. #include <sccsid.h>
  8.  
  9. /*
  10.  * This file defines a few things such as a base system environment
  11.  * (BSD/SYSV), and includes some support for ANSI Standard C.  It is, in some
  12.  * ways, analogous to the ANSI-C <stddef.h> header.  It also defines some
  13.  * common system data types that may be missing on some platforms.  It is
  14.  * intended to be included first, and to be followed at some point by
  15.  * <libc.h>.
  16.  */
  17.  
  18. /*
  19.  * NOTE:  In general you will not have to edit this file.  Custom features
  20.  * should be enabled via command-line defines if necessary (eg. -DDUMB_VOID).
  21.  */
  22.  
  23. /*
  24.  * WARNING:  This file uses '\' to continue '#if' lines
  25.  */
  26.  
  27. /*
  28.  * Determine if really ANSI C
  29.  */
  30. #if defined(__STDC__) && !defined(REALSTDC)
  31. # if (__STDC__ - 0) > 0
  32. #  define REALSTDC        1
  33. #  ifndef USE_PROTOTYPES
  34. #    define USE_PROTOTYPES    1    /* see use of this below */
  35. #  endif
  36. # else
  37. #  define REALSTDC        0
  38. # endif
  39. #else
  40. # define REALSTDC        0
  41. #endif
  42.  
  43. /*
  44.  * some compilers bitch about using 'extern' for "forward" references
  45.  */
  46. #if REALSTDC
  47. # define forward    /* implicit */
  48. #else
  49. # define forward    extern
  50. #endif
  51. #ifndef private
  52. # define private    static
  53. #endif
  54.  
  55. /*
  56.  * Some automated feature detection partially ripped out of JOVE 4.x
  57.  */
  58.  
  59. #if defined(ultrix) || defined(__ultrix__)
  60. # define ULTRIX
  61. # ifndef BSD4_2
  62. #  define BSD4_2    1    /* True enough for our purposes */
  63. # endif
  64. #endif
  65.  
  66. #if (defined(sun) || defined(__sun__)) /* && !defined(SUNOS5) */
  67. # define SUN
  68. # ifndef BSD4_2
  69. #  define BSD4_2    1    /* True enough for our purposes */
  70. # endif
  71. #endif
  72.  
  73. #if defined(mips) || defined(__mips__)
  74. # define MIPS
  75. # ifndef SYSVR3
  76. #  define SYSVR3    1
  77. # endif
  78. #endif
  79.  
  80. /* M_XENIX is defined by the Compiler */
  81.  
  82. /* SYSV should be defined for AT&T UNIX System V systems */
  83.  
  84. #ifdef SYSVR4
  85. # ifndef SYSVR3
  86. #  define SYSVR3    1    /* SYSVR3 is a subset of SYSVR4 */
  87. # endif
  88. #endif
  89. #ifdef SYSVR3
  90. # ifndef SYSVR2
  91. #  define SYSVR2    1    /* SYSVR2 is a subset of SYSVR3 */
  92. # endif
  93. #endif
  94. #ifdef SYSVR2
  95. # ifndef SYSV
  96. #  define SYSV        1    /* SYSV is a subset of SYSVR2 */
  97. # endif
  98. #endif
  99. #ifdef SYSVR1
  100. # ifndef SYSV
  101. #  define SYSV        1    /* SYSVR1 is SYSV! */
  102. # endif
  103. #endif
  104.  
  105. #ifdef BSD4_1
  106. # ifndef BSD
  107. #  define BSD    1
  108. # endif
  109. #endif
  110. #ifdef BSD4_2
  111. # ifndef BSD
  112. #  define BSD    1
  113. # endif
  114. #endif
  115. #ifdef BSD4_3
  116. # ifndef BSD
  117. #  define BSD    1
  118. # endif
  119. #endif
  120.  
  121. #ifdef BSD2_8
  122. # ifndef BSD
  123. #  define BSD    1
  124. # endif
  125. #endif
  126. #ifdef BSD2_9
  127. # ifndef BSD
  128. #  define BSD    1
  129. # endif
  130. #endif
  131. #ifdef BSD2_10
  132. # ifndef BSD
  133. #  define BSD    1
  134. # endif
  135. #endif
  136.  
  137. #if defined(BSD) || defined(V7) || defined(SYSIII) /* || defined(M_XENIX) 2.3 */
  138. # ifndef strchr
  139. #  define strchr    index
  140. # endif
  141. # ifndef strrchr
  142. #  define strrchr    rindex
  143. # endif
  144. #endif
  145.  
  146. #ifdef SYSV
  147. # ifndef HAVE_UNAME
  148. #  define HAVE_UNAME    1
  149. # endif
  150. #endif
  151.  
  152. #if !defined(SYSV) && !defined(M_XENIX) && \
  153.     !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
  154. # define NEED_LOCKF    1
  155. #endif
  156.  
  157. /*
  158.  * Legend says the old Microsoft mc68k C compiler (for XENIX/68000, and
  159.  * probably originally written by UniSoft) "noticed" if the code defined
  160.  * 'VOID' and suddenly supported the 'void' keyword, in which case constructs
  161.  * like the following may cause syntax errors or other weird behavior.
  162.  * (Personally I thought it was M_VOID that triggered this behavior.)
  163.  *
  164.  * NOTE:  we don't use a typedef here.
  165.  *
  166.  * NOTE:  See 'UnivPtr' below too!
  167.  */
  168. #ifndef DUMB_VOID
  169. # ifndef VOID
  170. #  define VOID    void    /* 'VOID' is used where half-baked compilers fail */
  171. # endif
  172. #else
  173. # undef VOID
  174. # define VOID    int
  175. # if defined(REDEF_VOID) && !defined(void)
  176. #  define void    int    /* Even Ritchie's V7 cc supported 'void'.... */
  177. # endif
  178. #endif
  179.  
  180. /*
  181.  * proto: macro to allow us to prototype any function declaration without
  182.  * upsetting old compilers.  Use it like this:
  183.  *
  184.  *    extern int    myfun proto(int arg1, char *arg2);
  185.  *    extern int    (*ptrtofun) ptrproto(void);
  186.  *    extern char    *morefun proto((char *(*proc) ptrproto((const char *))));
  187.  *    pattern = myproc("howdy", (int (*) ptrproto((int))) NULL, (char *) NULL);
  188.  *
  189.  * If you define this you'll likely need USE_STDARGS too.
  190.  */
  191. #if (REALSTDC == 1) || defined(USE_PROTOTYPES)
  192. # define proto(x)        x
  193. # ifdef    NO_PTRPROTO
  194.    /* on these systems, a prototype cannot be used for a pointer to function */
  195. #  define ptrproto(x)        ()
  196. # else
  197. #  define ptrproto(x)        x
  198. # endif
  199. #else
  200. # define proto(x)        ()
  201. # define ptrproto(x)        ()
  202. #endif
  203.  
  204. /*
  205.  * There are two ways to handle functions with a variable number of args.
  206.  * The old portable way uses <varargs.h>.  The way sanctioned by ANSI X3J11
  207.  * uses <stdarg.h>.  Unfortunately they are not compatible....  Note also
  208.  * that if you define this you'll probably need USE_PROTOTYPES too.
  209.  */
  210. #if (REALSTDC == 1) || defined(USE_STDARGS)
  211. # ifndef USE_STDARGS
  212. #  define USE_STDARGS        1
  213. # endif
  214. # define va_init(ap, parmN)    { va_start((ap), (parmN)); }
  215. #else
  216. # define va_init(ap, parmN)    { va_start((ap)); }
  217. #endif
  218.  
  219. /*
  220.  * 'const': readonly type qualifier (use may break some pre-ANSI compilers!)
  221.  */
  222. #if (REALSTDC == 0) && !defined(USE_CONST)
  223. # define const        /* Only in ANSI C.  Pity */
  224. #endif
  225.  
  226. /*
  227.  * 'volatile':  type qualifier indicating one of two kinds of magic:
  228.  *
  229.  * 1. This object may be modified by an event unknown to the implementation
  230.  *    (eg. asynchronous signal or memory-mapped I/O device).
  231.  *
  232.  * 2. This automatic variable might be modified between a setjmp()
  233.  *    and a longjmp(), and we wish it to have the correct value after
  234.  *    the longjmp().  This second meaning is an X3J11 abomination.
  235.  */
  236. #if (REALSTDC == 0) && !defined(USE_VOLATILE)
  237. # define volatile    /* also only in ANSI C.  Oh well. */
  238. #endif
  239.  
  240. /*
  241.  * 'signed': converse of 'unsigned'
  242.  */
  243. #if (REALSTDC == 0) && !defined(USE_SIGNED)
  244. # define signed        /* bye-bye! */
  245. #endif
  246.  
  247. /*
  248.  * UnivPtr: universal pointer type
  249.  */
  250. #if (REALSTDC == 1) || defined(USE_VOIDPTR)
  251. typedef void        Univ;
  252. typedef void        *UnivPtr;
  253. typedef const void    *UnivConstPtr;    /* object is "constant" */
  254. typedef void * const    UnivPtrConst;    /* pointer is "constant" */
  255. #else
  256. typedef char        Univ;
  257. typedef char        *UnivPtr;
  258. typedef const char    *UnivConstPtr;    /* object is "constant" */
  259. typedef char * const    UnivPtrConst;    /* pointer is "constant" */
  260. #endif
  261.  
  262. /*
  263.  * According to the ANSI standard for C, any library routine may
  264.  * be defined as a macro with parameters.  In order to prevent
  265.  * the expansion of this macro in a declaration of the routine,
  266.  * ANSI suggests parenthesizing the identifier.  This is a reasonable
  267.  * and legal approach, even for K&R C.
  268.  *
  269.  * A bug in the MIPS compiler used on MIPS, IRIS, and probably other
  270.  * MIPS R[23]000 based systems, causes the compiler to reject
  271.  * these declarations (at least at the current time, 1989 August).
  272.  * To avoid this bug, we conditionally define and use UNMACRO.
  273.  */
  274. #if defined(MIPS) /* || defined(IRIS) || defined(NEC) */
  275. # define UNMACRO(proc)    proc
  276. #else
  277. # define UNMACRO(proc)    (proc)
  278. #endif
  279.  
  280. /*
  281.  * This is a bit tricky.  Often, when compiling on a POSIX compatible system,
  282.  * one will *not* want to define _POSIX_SOURCE.  However, not doing so does
  283.  * not remove the typedefs from the system headers.  Perhaps the opposite
  284.  * logic should be used, and these should be defined *only* for those system
  285.  * variants that need them....  The problem being that some compilers get
  286.  * right upset if you try and re-typedef something, even if to the exact same
  287.  * fundamental type.  NOTE:  some are ushort, some ulong or long.
  288.  */
  289. #if !defined(SYSVR4) && !defined(_AIX) && \
  290.     !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
  291. # ifdef V7
  292. typedef int        uid_t;
  293. typedef int        gid_t;
  294. # else
  295. #  ifdef M_XENIX
  296. typedef unsigned short    uid_t;
  297. typedef unsigned short    gid_t;
  298. #  else
  299. /* typedef unsigned int    uid_t;
  300. typedef unsigned int    gid_t; */
  301. #  endif
  302. # endif
  303. #endif
  304.  
  305. /*
  306.  * size_t is required for at least for att-3b1 (defined(u3b)) and most M_XENIX
  307.  */
  308. #if !defined(_SIZE_T) && defined(NEED_SIZE_T) || ((REALSTDC == 0) && \
  309.     !defined(SYSVR2) && !defined(SYSVR3) && !defined(SYSVR4) && \
  310.     !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE))
  311. # define _SIZE_T    1        /* _AIX only? */
  312. typedef unsigned int    size_t;        /* int on some, ulong on some? */
  313. #endif
  314.  
  315. /*
  316.  * 8-bit type & 16-bit macros to avoid sign problems
  317.  */
  318. #ifndef NO_BYTE
  319. # if defined(V7) || defined(M_XENIX) || defined(BSD2_8)
  320. typedef char        byte;    /* WARNING: machine dependent! */
  321. #  define BYTE(x)    ((x) && 0xff)
  322. # else
  323. typedef unsigned char    byte;    /* WARNING: machine dependent! */
  324. #  define BYTE(x)    (x)
  325. # endif
  326. # define HIBYTE(x)    (((x) >> 8) & 0xff)    /* hi byte of short */
  327. # define LOBYTE(x)    ((x) & 0xff)        /* lo byte of short */
  328. # define HIWORD(x)    (((x) >> 16) & 0xffffL)    /* hi 16-bits of long */
  329. # define LOWORD(x)    ((x) & 0xffffL)        /* lo 16-bits of long */
  330. # define CHAR(x)    ((x) & 0x7f)
  331. # define WORD(x)    ((x) & 0xffffL)        /* i.e. 16-bit word */
  332. #endif
  333.  
  334. /*
  335.  * more ANSI-C types more properly found in <stddef.h>
  336.  */
  337. #if !defined(_WCHAR_T) && (defined(NEED_WCHAR_T) || (!defined(REALSTDC)))
  338. # define _WCHAR_T    1        /* _AIX only? */
  339. typedef unsigned short    wchar_t;
  340. #endif
  341. #if !defined(_PTRDIFF_T) && (defined(NEED_PTRDIFF_T) || (!defined(REALSTDC)))
  342. # define _PTRDIFF_T    1        /* _AIX only? */
  343. typedef long        ptrdiff_t;
  344. #endif
  345.  
  346. /*
  347.  * as Henry Spencer says, 'char *sprintf()' is stupid and archaic!
  348.  */
  349. #if !defined(BSD) && (REALSTDC == 0) && !defined(NEED_VSPRINTF) && \
  350.     !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
  351. typedef int    SPRINTF_T;
  352. #else
  353. typedef char    *SPRINTF_T;    /* WARNING: don't use this with vsprintf.shar */
  354. #endif
  355.  
  356. /*
  357.  * Offset of member MEMBER in a struct of type TYPE.
  358.  *
  359.  * WARNING:  compiler dependent!
  360.  */
  361. #if !defined(offsetof) && !defined(_AIX) && !defined(_ANSI_C_SOURCE)
  362. # define offsetof(TYPE, MEMBER)        ((size_t) &(((TYPE *)0)->MEMBER))
  363. #endif
  364.