1 /* NetHack 3.6 system.h $NHDT-Date: 1550268586 2019/02/15 22:09:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.17 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Robert Patrick Rankin, 2017. */
4 /* NetHack may be freely redistributed. See license for details. */
9 #if !defined(__cplusplus) && !defined(__GO32__)
13 /* some old <sys/types.h> may not define off_t and size_t; if your system is
14 * one of these, define them by hand below
16 #if (defined(VMS) && !defined(__GNUC__)) || defined(MAC)
20 #include <sys/types.h>
24 #if (defined(MICRO) && !defined(TOS)) || defined(ANCIENT_VAXC)
25 #if !defined(_SIZE_T) && !defined(__size_t) /* __size_t for CSet/2 */
27 #if !((defined(MSDOS) || defined(OS2)) \
28 && defined(_SIZE_T_DEFINED)) /* MSC 5.1 */
29 #if !(defined(__GNUC__) && defined(AMIGA))
30 typedef unsigned int size_t;
34 #endif /* MICRO && !TOS */
36 #if defined(__TURBOC__) || defined(MAC)
37 #include <time.h> /* time_t is not in <sys/types.h> */
39 #if defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC))
40 /* The Ultrix v3.0 <sys/types.h> seems to be very wrong. */
44 #if defined(ULTRIX) || defined(VMS)
47 #if defined(AZTEC) || defined(THINKC4) || defined(__TURBOC__)
51 #endif /* !__cplusplus && !__GO32__ */
53 /* You may want to change this to fit your system, as this is almost
54 * impossible to get right automatically.
55 * This is the type of signal handling functions.
57 #if !defined(OS2) && (defined(_MSC_VER) || defined(__TURBOC__) \
58 || defined(__SC__) || defined(WIN32))
59 #define SIG_RET_TYPE void(__cdecl *)(int)
62 #if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(__DECC)
63 #define SIG_RET_TYPE void (*)()
67 #if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4)
68 /* SVR3 is defined automatically by some systems */
69 #define SIG_RET_TYPE void (*)()
72 #ifndef SIG_RET_TYPE /* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */
73 #define SIG_RET_TYPE int (*)()
76 #if !defined(__cplusplus) && !defined(__GO32__)
78 #if defined(BSD) || defined(ULTRIX) || defined(RANDOM)
82 #if !defined(__SC__) && !defined(LINUX)
85 #if (!defined(SUNOS4) && !defined(bsdi) && !defined(__FreeBSD__)) \
87 E void FDECL(srandom, (unsigned int));
89 #if !defined(bsdi) && !defined(__FreeBSD__)
90 E int FDECL(srandom, (unsigned int));
95 E long NDECL(lrand48);
96 E void FDECL(srand48, (long));
101 #endif /* BSD || ULTRIX || RANDOM */
103 #if !defined(BSD) || defined(ultrix)
104 /* real BSD wants all these to return int */
106 E void FDECL(exit, (int));
108 /* compensate for some CSet/2 bogosities */
109 #if defined(OS2_CSET2) && defined(OS2_CSET2_VER_2)
116 #define getcwd _getcwd
117 #define setmode _setmode
118 #endif /* OS2_CSET2 && OS2_CSET2_VER_2 */
119 /* If flex thinks that we're not __STDC__ it declares free() to return
120 int and we die. We must use __STDC__ instead of NHSTDC because
121 the former is naturally what flex tests for. */
122 #if defined(__STDC__) || !defined(FLEX_SCANNER)
125 E void FDECL(free, (genericptr_t));
129 #if !defined(__SASC_60) && !defined(_DCC) && !defined(__SC__)
130 #if defined(AMIGA) && !defined(AZTEC_50) && !defined(__GNUC__)
131 E int FDECL(perror, (const char *));
133 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
134 E void FDECL(perror, (const char *));
141 E void FDECL(qsort, (genericptr_t, size_t, size_t,
142 int (*)(const genericptr, const genericptr)));
144 #if defined(BSD) || defined(ULTRIX)
147 #if !defined(LATTICE) && !defined(AZTEC_50)
148 E void FDECL(qsort, (genericptr_t, size_t, size_t,
149 int (*)(const genericptr, const genericptr)));
156 #if !defined(AZTEC_50) && !defined(__GNUC__)
157 /* may already be defined */
161 E int FDECL(lseek, (int, off_t, int));
163 E long FDECL(lseek, (int, off_t, int));
165 /* Ultrix 3.0 man page mistakenly says it returns an int. */
166 E int FDECL(write, (int, char *, int));
167 E int FDECL(link, (const char *, const char *));
169 #if !(defined(bsdi) || defined(VMS))
170 E long FDECL(lseek, (int, long, int));
171 #if defined(POSIX_TYPES) || defined(__TURBOC__)
172 E int FDECL(write, (int, const void *, unsigned));
174 #ifndef __MWERKS__ /* metrowerks defines write via universal headers */
175 E int FDECL(write, (int, genericptr_t, unsigned));
177 #endif /*?(POSIX_TYPES || __TURBOC__)*/
178 #endif /*!(bsdi || VMS)*/
181 #ifdef OS2_CSET2 /* IBM CSet/2 */
182 #ifdef OS2_CSET2_VER_1
183 E int FDECL(unlink, (char *));
185 E int FDECL(unlink, (const char *)); /* prototype is ok in ver >= 2 */
189 E int FDECL(unlink, (const char *));
193 #endif /* AZTEC_50 && __GNUC__ */
196 #ifndef __CONDITIONALMACROS__ /* universal headers */
197 E int FDECL(close, (int)); /* unistd.h */
198 E int FDECL(read, (int, char *, int)); /* unistd.h */
199 E int FDECL(chdir, (const char *)); /* unistd.h */
200 E char *FDECL(getcwd, (char *, int)); /* unistd.h */
203 E int FDECL(open, (const char *, int));
207 E int FDECL(close, (int));
209 E int FDECL(read, (int, genericptr_t, unsigned int));
211 E int FDECL(open, (const char *, int, ...));
212 E int FDECL(dup2, (int, int));
213 E int FDECL(setmode, (int, int));
216 #if defined(__TURBOC__)
217 E int FDECL(chdir, (const char *));
220 E int FDECL(chdir, (char *));
224 E char *FDECL(getcwd, (char *, int));
230 E int FDECL(close, (int));
231 E int FDECL(atoi, (const char *));
232 E long FDECL(atol, (const char *));
233 E int FDECL(chdir, (const char *));
234 #if !defined(ULTRIX_CC20) && !defined(__GNUC__)
235 E int FDECL(chmod, (const char *, int));
236 E mode_t FDECL(umask, (int));
238 E int FDECL(read, (int, genericptr_t, unsigned));
239 /* these aren't quite right, but this saves including lots of system files */
240 E int FDECL(stty, (int, genericptr_t));
241 E int FDECL(gtty, (int, genericptr_t));
242 E int FDECL(ioctl, (int, int, char *));
243 E int FDECL(isatty, (int)); /* 1==yes, 0==no, -1==error */
244 #include <sys/file.h>
245 #if defined(ULTRIX_PROTO) || defined(__GNUC__)
254 E int FDECL(abs, (int));
256 E int FDECL(atexit, (void (*)(void)));
257 E int FDECL(atoi, (const char *));
258 E long FDECL(atol, (const char *));
259 E int FDECL(chdir, (const char *));
260 E int FDECL(chown, (const char *, unsigned, unsigned));
262 E int FDECL(chmod, (const char *, mode_t));
263 E mode_t FDECL(umask, (mode_t));
265 E int FDECL(chmod, (const char *, int));
266 E int FDECL(umask, (int));
268 /* #include <unixio.h> */
269 E int FDECL(close, (int));
270 E int VDECL(creat, (const char *, unsigned, ...));
271 E int FDECL(delete, (const char *));
272 E int FDECL(fstat, (/*_ int, stat_t * _*/));
273 E int FDECL(isatty, (int)); /* 1==yes, 0==no, -1==error */
274 E off_t FDECL(lseek, (int, off_t, int));
275 E int VDECL(open, (const char *, int, unsigned, ...));
276 E int FDECL(read, (int, genericptr_t, unsigned));
277 E int FDECL(rename, (const char *, const char *));
278 E int FDECL(stat, (/*_ const char *,stat_t * _*/));
279 E int FDECL(write, (int, const genericptr, unsigned));
282 #endif /* __SASC_60 */
284 /* both old & new versions of Ultrix want these, but real BSD does not */
289 E int FDECL(system, (const char *));
291 E int FDECL(execl, (const char *, ...));
297 E void FDECL(_exit, (int));
298 E int FDECL(system, (const char *));
300 #if defined(HPUX) && !defined(_POSIX_SOURCE)
305 /* The POSIX string.h is required to define all the mem* and str* functions */
308 #if defined(SYSV) || defined(VMS) || defined(MAC) || defined(SUNOS4)
309 #if defined(NHSTDC) || (defined(VMS) && !defined(ANCIENT_VAXC))
310 #if !defined(_AIX32) && !(defined(SUNOS4) && defined(__STDC__))
311 /* Solaris unbundled cc (acc) */
312 E int FDECL(memcmp, (const void *, const void *, size_t));
313 E void *FDECL(memcpy, (void *, const void *, size_t));
314 E void *FDECL(memset, (void *, int, size_t));
317 #ifndef memcmp /* some systems seem to macro these back to b*() */
329 E int FDECL(memcmp, (char *, char *, int));
330 E void *FDECL(memcpy, (char *, char *, int));
331 E void *FDECL(memset, (char *, int, int));
334 #endif /* POSIX_TYPES */
336 #if defined(MICRO) && !defined(LATTICE)
337 #if defined(TOS) && defined(__GNUC__)
338 E int FDECL(memcmp, (const void *, const void *, size_t));
339 E void *FDECL(memcpy, (void *, const void *, size_t));
340 E void *FDECL(memset, (void *, int, size_t));
342 #if defined(AZTEC_50) || defined(NHSTDC) || defined(WIN32)
343 E int FDECL(memcmp, (const void *, const void *, size_t));
344 E void *FDECL(memcpy, (void *, const void *, size_t));
345 E void *FDECL(memset, (void *, int, size_t));
347 E int FDECL(memcmp, (char *, char *, unsigned int));
348 E char *FDECL(memcpy, (char *, char *, unsigned int));
349 E char *FDECL(memset, (char *, int, int));
350 #endif /* AZTEC_50 || NHSTDC */
354 #if defined(BSD) && defined(ultrix) /* i.e., old versions of Ultrix */
357 #if defined(ULTRIX) || defined(SYSV)
361 E unsigned int FDECL(sleep, (unsigned int));
364 E int FDECL(sleep, (unsigned));
367 E char *FDECL(getenv, (const char *));
369 #if defined(HPUX) && !defined(_POSIX_SOURCE)
370 E long NDECL(getuid);
371 E long NDECL(getgid);
372 E long NDECL(getpid);
375 E pid_t NDECL(getpid);
376 E uid_t NDECL(getuid);
377 E gid_t NDECL(getgid);
379 E pid_t NDECL(getppid);
381 #else /*!POSIX_TYPES*/
382 #ifndef getpid /* Borland C defines getpid() as a macro */
386 E int NDECL(getppid);
387 E unsigned NDECL(getuid);
388 E unsigned NDECL(getgid);
390 #if defined(ULTRIX) && !defined(_UNISTD_H_)
391 E unsigned NDECL(getuid);
392 E unsigned NDECL(getgid);
393 E int FDECL(setgid, (int));
394 E int FDECL(setuid, (int));
396 #endif /*?POSIX_TYPES*/
397 #endif /*?(HPUX && !_POSIX_SOURCE)*/
399 /* add more architectures as needed */
401 #define seteuid(x) setreuid(-1, (x));
405 #if !defined(_XtIntrinsic_h) && !defined(POSIX_TYPES)
406 /* <X11/Intrinsic.h> #includes <string[s].h>; so does defining POSIX_TYPES */
408 #if (defined(ULTRIX) || defined(NeXT)) && defined(__GNUC__)
411 E char *FDECL(strcpy, (char *, const char *));
412 E char *FDECL(strncpy, (char *, const char *, size_t));
413 E char *FDECL(strcat, (char *, const char *));
414 E char *FDECL(strncat, (char *, const char *, size_t));
415 E char *FDECL(strpbrk, (const char *, const char *));
417 #if defined(SYSV) || defined(MICRO) || defined(MAC) || defined(VMS) \
419 E char *FDECL(strchr, (const char *, int));
420 E char *FDECL(strrchr, (const char *, int));
422 E char *FDECL(index, (const char *, int));
423 E char *FDECL(rindex, (const char *, int));
426 E int FDECL(strcmp, (const char *, const char *));
427 E int FDECL(strncmp, (const char *, const char *, size_t));
428 #if defined(MICRO) || defined(MAC) || defined(VMS)
429 E size_t FDECL(strlen, (const char *));
432 E unsigned int FDECL(strlen, (char *));
434 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
435 E int FDECL(strlen, (const char *));
441 #endif /* !_XtIntrinsic_h_ && !POSIX_TYPES */
443 #if defined(ULTRIX) && defined(__GNUC__)
444 E char *FDECL(index, (const char *, int));
445 E char *FDECL(rindex, (const char *, int));
448 /* Old varieties of BSD have char *sprintf().
449 * Newer varieties of BSD have int sprintf() but allow for the old char *.
450 * Several varieties of SYSV and PC systems also have int sprintf().
451 * If your system doesn't agree with this breakdown, you may want to change
452 * this declaration, especially if your machine treats the types differently.
453 * If your system defines sprintf, et al, in stdio.h, add to the initial
456 #if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || defined(WIN32)
457 #define SPRINTF_PROTO
459 #if (defined(SUNOS4) && defined(__STDC__)) || defined(_AIX32)
460 #define SPRINTF_PROTO
462 #if defined(TOS) || defined(AZTEC_50) || defined(__sgi) || defined(__GNUC__)
463 /* problem with prototype mismatches */
464 #define SPRINTF_PROTO
466 #if defined(__MWERKS__) || defined(__SC__)
467 /* Metrowerks already has a prototype for sprintf() */
468 #define SPRINTF_PROTO
471 #ifndef SPRINTF_PROTO
472 #if defined(POSIX_TYPES) || defined(DGUX) || defined(NeXT) || !defined(BSD)
473 E int FDECL(sprintf, (char *, const char *, ...));
485 #if defined(USE_STDARG) || defined(USE_VARARGS)
486 #if !defined(SVR4) && !defined(apollo)
487 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
488 #if !(defined(SUNOS4) && defined(__STDC__)) /* Solaris unbundled cc (acc) */
489 E int FDECL(vsprintf, (char *, const char *, va_list));
490 E int FDECL(vfprintf, (FILE *, const char *, va_list));
491 E int FDECL(vprintf, (const char *, va_list));
499 #define vprintf printf
503 #define vfprintf fprintf
507 #define vsprintf sprintf
509 #endif /* NEED_VARARGS */
513 E int FDECL(tgetent, (const char *, const char *));
514 E void FDECL(tputs, (const char *, int, int (*)()));
515 E int FDECL(tgetnum, (const char *));
516 E int FDECL(tgetflag, (const char *));
517 E char *FDECL(tgetstr, (const char *, char **));
518 E char *FDECL(tgoto, (const char *, int, int));
520 #if !(defined(HPUX) && defined(_POSIX_SOURCE))
521 E int FDECL(tgetent, (char *, const char *));
522 E void FDECL(tputs, (const char *, int, int (*)()));
524 E int FDECL(tgetnum, (const char *));
525 E int FDECL(tgetflag, (const char *));
526 E char *FDECL(tgetstr, (const char *, char **));
527 E char *FDECL(tgoto, (const char *, int, int));
530 #if defined(ALLOC_C) || defined(MAKEDEFS_C)
531 E genericptr_t FDECL(malloc, (size_t));
532 E genericptr_t FDECL(realloc, (genericptr_t, size_t));
538 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
539 E struct tm *FDECL(localtime, (const time_t *));
543 #if defined(ULTRIX) || (defined(BSD) && defined(POSIX_TYPES)) \
544 || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) \
545 || (defined(HPUX) && defined(_POSIX_SOURCE))
546 E time_t FDECL(time, (time_t *));
548 E long FDECL(time, (time_t *));
552 /* used in makedefs.c, but missing from gcc-vms's <time.h> */
553 E char *FDECL(ctime, (const time_t *));
560 E int FDECL(abs, (int));
564 E int FDECL(atoi, (const char *));
569 #endif /* !__cplusplus && !__GO32__ */
571 #endif /* SYSTEM_H */