1 /* SCCS Id: @(#)system.h 3.4 2001/12/07 */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
8 #if !defined(__cplusplus) && !defined(__GO32__)
12 /* some old <sys/types.h> may not define off_t and size_t; if your system is
13 * one of these, define them by hand below
15 #if (defined(VMS) && !defined(__GNUC__)) || defined(MAC)
19 #include <sys/types.h>
23 #if (defined(MICRO) && !defined(TOS)) || defined(ANCIENT_VAXC)
24 # if !defined(_SIZE_T) && !defined(__size_t) /* __size_t for CSet/2 */
26 # if !((defined(MSDOS) || defined(OS2)) && defined(_SIZE_T_DEFINED)) /* MSC 5.1 */
27 # if !(defined(__GNUC__) && defined(AMIGA))
28 typedef unsigned int size_t;
32 #endif /* MICRO && !TOS */
34 #if defined(__TURBOC__) || defined(MAC)
35 #include <time.h> /* time_t is not in <sys/types.h> */
37 #if defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC))
38 /* The Ultrix v3.0 <sys/types.h> seems to be very wrong. */
42 #if defined(ULTRIX) || defined(VMS)
45 #if defined(AZTEC) || defined(THINKC4) || defined(__TURBOC__)
49 #endif /* !__cplusplus && !__GO32__ */
51 /* You may want to change this to fit your system, as this is almost
52 * impossible to get right automatically.
53 * This is the type of signal handling functions.
55 #if !defined(OS2) && (defined(_MSC_VER) || defined(__TURBOC__) || defined(__SC__) || defined(WIN32))
56 # define SIG_RET_TYPE void (__cdecl *)(int)
59 # if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(__DECC)
60 # define SIG_RET_TYPE void (*)()
64 # if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4)
65 /* SVR3 is defined automatically by some systems */
66 # define SIG_RET_TYPE void (*)()
69 #ifndef SIG_RET_TYPE /* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */
70 # define SIG_RET_TYPE int (*)()
73 #if !defined(__cplusplus) && !defined(__GO32__)
75 #if defined(BSD) || defined(ULTRIX) || defined(RANDOM)
79 # if !defined(__SC__) && !defined(LINUX)
82 # if (!defined(SUNOS4) && !defined(bsdi) && !defined(__FreeBSD__)) || defined(RANDOM)
83 E void FDECL(srandom, (unsigned int));
85 # if !defined(bsdi) && !defined(__FreeBSD__)
86 E int FDECL(srandom, (unsigned int));
92 #endif /* BSD || ULTRIX || RANDOM */
94 #if !defined(BSD) || defined(ultrix)
95 /* real BSD wants all these to return int */
97 E void FDECL(exit, (int));
99 /* compensate for some CSet/2 bogosities */
100 # if defined(OS2_CSET2) && defined(OS2_CSET2_VER_2)
102 # define close _close
104 # define write _write
105 # define lseek _lseek
106 # define chdir _chdir
107 # define getcwd _getcwd
108 # define setmode _setmode
109 # endif /* OS2_CSET2 && OS2_CSET2_VER_2 */
110 /* If flex thinks that we're not __STDC__ it declares free() to return
111 int and we die. We must use __STDC__ instead of NHSTDC because
112 the former is naturally what flex tests for. */
113 # if defined(__STDC__) || !defined(FLEX_SCANNER)
115 # ifndef MONITOR_HEAP
116 E void FDECL(free, (genericptr_t));
120 #if !defined(__SASC_60) && !defined(_DCC) && !defined(__SC__)
121 # if defined(AMIGA) && !defined(AZTEC_50) && !defined(__GNUC__)
122 E int FDECL(perror, (const char *));
124 # if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
125 E void FDECL(perror, (const char *));
132 E void FDECL(qsort, (genericptr_t,size_t,size_t,
133 int(*)(const genericptr,const genericptr)));
135 # if defined(BSD) || defined(ULTRIX)
138 # if !defined(LATTICE) && !defined(AZTEC_50)
139 E void FDECL(qsort, (genericptr_t,size_t,size_t,
140 int(*)(const genericptr,const genericptr)));
147 #if !defined(AZTEC_50) && !defined(__GNUC__)
148 /* may already be defined */
152 E int FDECL(lseek, (int,off_t,int));
154 E long FDECL(lseek, (int,off_t,int));
156 /* Ultrix 3.0 man page mistakenly says it returns an int. */
157 E int FDECL(write, (int,char *,int));
158 E int FDECL(link, (const char *, const char*));
161 E long FDECL(lseek, (int,long,int));
163 # if defined(POSIX_TYPES) || defined(__TURBOC__)
165 E int FDECL(write, (int, const void *,unsigned));
168 # ifndef __MWERKS__ /* metrowerks defines write via universal headers */
169 E int FDECL(write, (int,genericptr_t,unsigned));
174 # ifdef OS2_CSET2 /* IBM CSet/2 */
175 # ifdef OS2_CSET2_VER_1
176 E int FDECL(unlink, (char *));
178 E int FDECL(unlink, (const char *)); /* prototype is ok in ver >= 2 */
182 E int FDECL(unlink, (const char *));
186 #endif /* AZTEC_50 && __GNUC__ */
189 #ifndef __CONDITIONALMACROS__ /* universal headers */
190 E int FDECL(close, (int)); /* unistd.h */
191 E int FDECL(read, (int, char *, int)); /* unistd.h */
192 E int FDECL(chdir, (const char *)); /* unistd.h */
193 E char *FDECL(getcwd, (char *,int)); /* unistd.h */
196 E int FDECL(open, (const char *,int));
200 E int FDECL(close, (int));
202 E int FDECL(read, (int,genericptr_t,unsigned int));
204 E int FDECL(open, (const char *,int,...));
205 E int FDECL(dup2, (int, int));
206 E int FDECL(setmode, (int,int));
209 # if defined(__TURBOC__)
210 E int FDECL(chdir, (const char *));
213 E int FDECL(chdir, (char *));
217 E char *FDECL(getcwd, (char *,int));
223 E int FDECL(close, (int));
224 E int FDECL(atoi, (const char *));
225 E int FDECL(chdir, (const char *));
226 # if !defined(ULTRIX_CC20) && !defined(__GNUC__)
227 E int FDECL(chmod, (const char *,int));
228 E mode_t FDECL(umask, (int));
230 E int FDECL(read, (int,genericptr_t,unsigned));
231 /* these aren't quite right, but this saves including lots of system files */
232 E int FDECL(stty, (int,genericptr_t));
233 E int FDECL(gtty, (int,genericptr_t));
234 E int FDECL(ioctl, (int, int, char*));
235 E int FDECL(isatty, (int)); /* 1==yes, 0==no, -1==error */
236 #include <sys/file.h>
237 # if defined(ULTRIX_PROTO) || defined(__GNUC__)
246 E int FDECL(abs, (int));
248 E int FDECL(atexit, (void (*)(void)));
249 E int FDECL(atoi, (const char *));
250 E int FDECL(chdir, (const char *));
251 E int FDECL(chown, (const char *,unsigned,unsigned));
253 E int FDECL(chmod, (const char *,mode_t));
254 E mode_t FDECL(umask, (mode_t));
256 E int FDECL(chmod, (const char *,int));
257 E int FDECL(umask, (int));
259 /* #include <unixio.h> */
260 E int FDECL(close, (int));
261 E int VDECL(creat, (const char *,unsigned,...));
262 E int FDECL(delete, (const char *));
263 E int FDECL(fstat, ( /*_ int, stat_t * _*/ ));
264 E int FDECL(isatty, (int)); /* 1==yes, 0==no, -1==error */
265 E long FDECL(lseek, (int,long,int));
266 E int VDECL(open, (const char *,int,unsigned,...));
267 E int FDECL(read, (int,genericptr_t,unsigned));
268 E int FDECL(rename, (const char *,const char *));
269 E int FDECL(stat, ( /*_ const char *,stat_t * _*/ ));
270 E int FDECL(write, (int,const genericptr,unsigned));
273 #endif /* __SASC_60 */
275 /* both old & new versions of Ultrix want these, but real BSD does not */
280 E int FDECL(system, (const char *));
282 E int FDECL(execl, (const char *, ...));
288 E void FDECL(_exit, (int));
289 E int FDECL(system, (const char *));
291 #if defined(HPUX) && !defined(_POSIX_SOURCE)
296 /* The POSIX string.h is required to define all the mem* and str* functions */
299 #if defined(SYSV) || defined(VMS) || defined(MAC) || defined(SUNOS4)
300 # if defined(NHSTDC) || (defined(VMS) && !defined(ANCIENT_VAXC))
301 # if !defined(_AIX32) && !(defined(SUNOS4) && defined(__STDC__))
302 /* Solaris unbundled cc (acc) */
303 E int FDECL(memcmp, (const void *,const void *,size_t));
304 E void *FDECL(memcpy, (void *, const void *, size_t));
305 E void *FDECL(memset, (void *, int, size_t));
308 # ifndef memcmp /* some systems seem to macro these back to b*() */
320 E int FDECL(memcmp, (char *,char *,int));
321 E void *FDECL(memcpy, (char *,char *,int));
322 E void *FDECL(memset, (char*,int,int));
325 #endif /* POSIX_TYPES */
327 #if defined(MICRO) && !defined(LATTICE)
328 # if defined(TOS) && defined(__GNUC__)
329 E int FDECL(memcmp, (const void *,const void *,size_t));
330 E void *FDECL(memcpy, (void *,const void *,size_t));
331 E void *FDECL(memset, (void *,int,size_t));
333 # if defined(AZTEC_50) || defined(NHSTDC) || defined(WIN32)
334 E int FDECL(memcmp, (const void *, const void *, size_t));
335 E void *FDECL(memcpy, (void *, const void *, size_t));
336 E void *FDECL(memset, (void *, int, size_t));
338 E int FDECL(memcmp, (char *,char *,unsigned int));
339 E char *FDECL(memcpy, (char *,char *,unsigned int));
340 E char *FDECL(memset, (char*,int,int));
341 # endif /* AZTEC_50 || NHSTDC */
345 #if defined(BSD) && defined(ultrix) /* i.e., old versions of Ultrix */
348 #if defined(ULTRIX) || defined(SYSV)
352 E unsigned int FDECL(sleep, (unsigned int));
355 E int FDECL(sleep, (unsigned));
358 E char *FDECL(getenv, (const char *));
360 #if defined(HPUX) && !defined(_POSIX_SOURCE)
361 E long NDECL(getuid);
362 E long NDECL(getgid);
363 E long NDECL(getpid);
366 E pid_t NDECL(getpid);
367 E uid_t NDECL(getuid);
368 E gid_t NDECL(getgid);
370 E pid_t NDECL(getppid);
372 # else /*!POSIX_TYPES*/
373 # ifndef getpid /* Borland C defines getpid() as a macro */
377 E int NDECL(getppid);
378 E unsigned NDECL(getuid);
379 E unsigned NDECL(getgid);
381 # if defined(ULTRIX) && !defined(_UNISTD_H_)
382 E unsigned NDECL(getuid);
383 E unsigned NDECL(getgid);
384 E int FDECL(setgid, (int));
385 E int FDECL(setuid, (int));
387 # endif /*?POSIX_TYPES*/
388 #endif /*?(HPUX && !_POSIX_SOURCE)*/
390 /* add more architectures as needed */
392 #define seteuid(x) setreuid(-1, (x));
396 #if !defined(_XtIntrinsic_h) && !defined(POSIX_TYPES)
397 /* <X11/Intrinsic.h> #includes <string[s].h>; so does defining POSIX_TYPES */
399 #if (defined(ULTRIX) || defined(NeXT)) && defined(__GNUC__)
402 E char *FDECL(strcpy, (char *,const char *));
403 E char *FDECL(strncpy, (char *,const char *,size_t));
404 E char *FDECL(strcat, (char *,const char *));
405 E char *FDECL(strncat, (char *,const char *,size_t));
406 E char *FDECL(strpbrk, (const char *,const char *));
408 # if defined(SYSV) || defined(MICRO) || defined(MAC) || defined(VMS) || defined(HPUX)
409 E char *FDECL(strchr, (const char *,int));
410 E char *FDECL(strrchr, (const char *,int));
412 E char *FDECL(index, (const char *,int));
413 E char *FDECL(rindex, (const char *,int));
416 E int FDECL(strcmp, (const char *,const char *));
417 E int FDECL(strncmp, (const char *,const char *,size_t));
418 # if defined(MICRO) || defined(MAC) || defined(VMS)
419 E size_t FDECL(strlen, (const char *));
422 E unsigned int FDECL(strlen, (char *));
424 # if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
425 E int FDECL(strlen, (const char *));
431 #endif /* !_XtIntrinsic_h_ && !POSIX_TYPES */
433 #if defined(ULTRIX) && defined(__GNUC__)
434 E char *FDECL(index, (const char *,int));
435 E char *FDECL(rindex, (const char *,int));
438 /* Old varieties of BSD have char *sprintf().
439 * Newer varieties of BSD have int sprintf() but allow for the old char *.
440 * Several varieties of SYSV and PC systems also have int sprintf().
441 * If your system doesn't agree with this breakdown, you may want to change
442 * this declaration, especially if your machine treats the types differently.
443 * If your system defines sprintf, et al, in stdio.h, add to the initial
446 #if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || defined(WIN32)
447 #define SPRINTF_PROTO
449 #if (defined(SUNOS4) && defined(__STDC__)) || defined(_AIX32)
450 #define SPRINTF_PROTO
452 #if defined(TOS) || defined(AZTEC_50) || defined(__sgi) || defined(__GNUC__)
453 /* problem with prototype mismatches */
454 #define SPRINTF_PROTO
456 #if defined(__MWERKS__) || defined(__SC__)
457 /* Metrowerks already has a prototype for sprintf() */
458 # define SPRINTF_PROTO
461 #ifndef SPRINTF_PROTO
462 # if defined(POSIX_TYPES) || defined(DGUX) || defined(NeXT) || !defined(BSD)
463 E int FDECL(sprintf, (char *,const char *,...));
470 # undef SPRINTF_PROTO
475 # if defined(USE_STDARG) || defined(USE_VARARGS)
476 # if !defined(SVR4) && !defined(apollo)
477 # if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
478 # if !(defined(SUNOS4) && defined(__STDC__)) /* Solaris unbundled cc (acc) */
479 E int FDECL(vsprintf, (char *, const char *, va_list));
480 E int FDECL(vfprintf, (FILE *, const char *, va_list));
481 E int FDECL(vprintf, (const char *, va_list));
486 # define vprintf printf
487 # define vfprintf fprintf
488 # define vsprintf sprintf
490 #endif /* NEED_VARARGS */
495 E int FDECL(tgetent, (const char *,const char *));
496 E void FDECL(tputs, (const char *,int,int (*)()));
497 E int FDECL(tgetnum, (const char *));
498 E int FDECL(tgetflag, (const char *));
499 E char *FDECL(tgetstr, (const char *,char **));
500 E char *FDECL(tgoto, (const char *,int,int));
502 # if ! (defined(HPUX) && defined(_POSIX_SOURCE))
503 E int FDECL(tgetent, (char *,const char *));
504 E void FDECL(tputs, (const char *,int,int (*)()));
506 E int FDECL(tgetnum, (const char *));
507 E int FDECL(tgetflag, (const char *));
508 E char *FDECL(tgetstr, (const char *,char **));
509 E char *FDECL(tgoto, (const char *,int,int));
513 E genericptr_t FDECL(malloc, (size_t));
519 # if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
520 E struct tm *FDECL(localtime, (const time_t *));
524 # if defined(ULTRIX) || (defined(BSD) && defined(POSIX_TYPES)) || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) || (defined(HPUX) && defined(_POSIX_SOURCE))
525 E time_t FDECL(time, (time_t *));
527 E long FDECL(time, (time_t *));
531 /* used in makedefs.c, but missing from gcc-vms's <time.h> */
532 E char *FDECL(ctime, (const time_t *));
540 E int FDECL(abs, (int));
544 E int FDECL(atoi, (const char *));
549 #endif /* !__cplusplus && !__GO32__ */
551 #endif /* SYSTEM_H */