1 /* NetHack 3.6 system.h $NHDT-Date: 1449269772 2015/12/04 22:56:12 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.12 $ */
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)) \
27 && defined(_SIZE_T_DEFINED)) /* MSC 5.1 */
28 #if !(defined(__GNUC__) && defined(AMIGA))
29 typedef unsigned int size_t;
33 #endif /* MICRO && !TOS */
35 #if defined(__TURBOC__) || defined(MAC)
36 #include <time.h> /* time_t is not in <sys/types.h> */
38 #if defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC))
39 /* The Ultrix v3.0 <sys/types.h> seems to be very wrong. */
43 #if defined(ULTRIX) || defined(VMS)
46 #if defined(AZTEC) || defined(THINKC4) || defined(__TURBOC__)
50 #endif /* !__cplusplus && !__GO32__ */
52 /* You may want to change this to fit your system, as this is almost
53 * impossible to get right automatically.
54 * This is the type of signal handling functions.
56 #if !defined(OS2) && (defined(_MSC_VER) || defined(__TURBOC__) \
57 || defined(__SC__) || defined(WIN32))
58 #define SIG_RET_TYPE void(__cdecl *)(int)
61 #if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(__DECC)
62 #define SIG_RET_TYPE void (*)()
66 #if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4)
67 /* SVR3 is defined automatically by some systems */
68 #define SIG_RET_TYPE void (*)()
71 #ifndef SIG_RET_TYPE /* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */
72 #define SIG_RET_TYPE int (*)()
75 #if !defined(__cplusplus) && !defined(__GO32__)
77 #if defined(BSD) || defined(ULTRIX) || defined(RANDOM)
81 #if !defined(__SC__) && !defined(LINUX)
84 #if (!defined(SUNOS4) && !defined(bsdi) && !defined(__FreeBSD__)) \
86 E
void FDECL(srandom
, (unsigned int));
88 #if !defined(bsdi) && !defined(__FreeBSD__)
89 E
int FDECL(srandom
, (unsigned int));
95 #endif /* BSD || ULTRIX || RANDOM */
97 #if !defined(BSD) || defined(ultrix)
98 /* real BSD wants all these to return int */
100 E
void FDECL(exit
, (int));
102 /* compensate for some CSet/2 bogosities */
103 #if defined(OS2_CSET2) && defined(OS2_CSET2_VER_2)
110 #define getcwd _getcwd
111 #define setmode _setmode
112 #endif /* OS2_CSET2 && OS2_CSET2_VER_2 */
113 /* If flex thinks that we're not __STDC__ it declares free() to return
114 int and we die. We must use __STDC__ instead of NHSTDC because
115 the former is naturally what flex tests for. */
116 #if defined(__STDC__) || !defined(FLEX_SCANNER)
119 E
void FDECL(free
, (genericptr_t
));
123 #if !defined(__SASC_60) && !defined(_DCC) && !defined(__SC__)
124 #if defined(AMIGA) && !defined(AZTEC_50) && !defined(__GNUC__)
125 E
int FDECL(perror
, (const char *));
127 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
128 E
void FDECL(perror
, (const char *));
135 E
void FDECL(qsort
, (genericptr_t
, size_t, size_t,
136 int (*)(const genericptr
, const genericptr
)));
138 #if defined(BSD) || defined(ULTRIX)
141 #if !defined(LATTICE) && !defined(AZTEC_50)
142 E
void FDECL(qsort
, (genericptr_t
, size_t, size_t,
143 int (*)(const genericptr
, const genericptr
)));
150 #if !defined(AZTEC_50) && !defined(__GNUC__)
151 /* may already be defined */
155 E
int FDECL(lseek
, (int, off_t
, int));
157 E
long FDECL(lseek
, (int, off_t
, int));
159 /* Ultrix 3.0 man page mistakenly says it returns an int. */
160 E
int FDECL(write
, (int, char *, int));
161 E
int FDECL(link
, (const char *, const char *));
164 E
long FDECL(lseek
, (int, long, int));
166 #if defined(POSIX_TYPES) || defined(__TURBOC__)
168 E
int FDECL(write
, (int, const void *, unsigned));
171 #ifndef __MWERKS__ /* metrowerks defines write via universal headers */
172 E
int FDECL(write
, (int, genericptr_t
, unsigned));
177 #ifdef OS2_CSET2 /* IBM CSet/2 */
178 #ifdef OS2_CSET2_VER_1
179 E
int FDECL(unlink
, (char *));
181 E
int FDECL(unlink
, (const char *)); /* prototype is ok in ver >= 2 */
185 E
int FDECL(unlink
, (const char *));
189 #endif /* AZTEC_50 && __GNUC__ */
192 #ifndef __CONDITIONALMACROS__ /* universal headers */
193 E
int FDECL(close
, (int)); /* unistd.h */
194 E
int FDECL(read
, (int, char *, int)); /* unistd.h */
195 E
int FDECL(chdir
, (const char *)); /* unistd.h */
196 E
char *FDECL(getcwd
, (char *, int)); /* unistd.h */
199 E
int FDECL(open
, (const char *, int));
203 E
int FDECL(close
, (int));
205 E
int FDECL(read
, (int, genericptr_t
, unsigned int));
207 E
int FDECL(open
, (const char *, int, ...));
208 E
int FDECL(dup2
, (int, int));
209 E
int FDECL(setmode
, (int, int));
212 #if defined(__TURBOC__)
213 E
int FDECL(chdir
, (const char *));
216 E
int FDECL(chdir
, (char *));
220 E
char *FDECL(getcwd
, (char *, int));
226 E
int FDECL(close
, (int));
227 E
int FDECL(atoi
, (const char *));
228 E
long FDECL(atol
, (const char *));
229 E
int FDECL(chdir
, (const char *));
230 #if !defined(ULTRIX_CC20) && !defined(__GNUC__)
231 E
int FDECL(chmod
, (const char *, int));
232 E mode_t
FDECL(umask
, (int));
234 E
int FDECL(read
, (int, genericptr_t
, unsigned));
235 /* these aren't quite right, but this saves including lots of system files */
236 E
int FDECL(stty
, (int, genericptr_t
));
237 E
int FDECL(gtty
, (int, genericptr_t
));
238 E
int FDECL(ioctl
, (int, int, char *));
239 E
int FDECL(isatty
, (int)); /* 1==yes, 0==no, -1==error */
240 #include <sys/file.h>
241 #if defined(ULTRIX_PROTO) || defined(__GNUC__)
250 E
int FDECL(abs
, (int));
252 E
int FDECL(atexit
, (void (*)(void)));
253 E
int FDECL(atoi
, (const char *));
254 E
long FDECL(atol
, (const char *));
255 E
int FDECL(chdir
, (const char *));
256 E
int FDECL(chown
, (const char *, unsigned, unsigned));
258 E
int FDECL(chmod
, (const char *, mode_t
));
259 E mode_t
FDECL(umask
, (mode_t
));
261 E
int FDECL(chmod
, (const char *, int));
262 E
int FDECL(umask
, (int));
264 /* #include <unixio.h> */
265 E
int FDECL(close
, (int));
266 E
int VDECL(creat
, (const char *, unsigned, ...));
267 E
int FDECL(delete, (const char *));
268 E
int FDECL(fstat
, (/*_ int, stat_t * _*/));
269 E
int FDECL(isatty
, (int)); /* 1==yes, 0==no, -1==error */
270 E
long FDECL(lseek
, (int, long, int));
271 E
int VDECL(open
, (const char *, int, unsigned, ...));
272 E
int FDECL(read
, (int, genericptr_t
, unsigned));
273 E
int FDECL(rename
, (const char *, const char *));
274 E
int FDECL(stat
, (/*_ const char *,stat_t * _*/));
275 E
int FDECL(write
, (int, const genericptr
, unsigned));
278 #endif /* __SASC_60 */
280 /* both old & new versions of Ultrix want these, but real BSD does not */
285 E
int FDECL(system
, (const char *));
287 E
int FDECL(execl
, (const char *, ...));
293 E
void FDECL(_exit
, (int));
294 E
int FDECL(system
, (const char *));
296 #if defined(HPUX) && !defined(_POSIX_SOURCE)
301 /* The POSIX string.h is required to define all the mem* and str* functions */
304 #if defined(SYSV) || defined(VMS) || defined(MAC) || defined(SUNOS4)
305 #if defined(NHSTDC) || (defined(VMS) && !defined(ANCIENT_VAXC))
306 #if !defined(_AIX32) && !(defined(SUNOS4) && defined(__STDC__))
307 /* Solaris unbundled cc (acc) */
308 E
int FDECL(memcmp
, (const void *, const void *, size_t));
309 E
void *FDECL(memcpy
, (void *, const void *, size_t));
310 E
void *FDECL(memset
, (void *, int, size_t));
313 #ifndef memcmp /* some systems seem to macro these back to b*() */
325 E
int FDECL(memcmp
, (char *, char *, int));
326 E
void *FDECL(memcpy
, (char *, char *, int));
327 E
void *FDECL(memset
, (char *, int, int));
330 #endif /* POSIX_TYPES */
332 #if defined(MICRO) && !defined(LATTICE)
333 #if defined(TOS) && defined(__GNUC__)
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 #if defined(AZTEC_50) || defined(NHSTDC) || defined(WIN32)
339 E
int FDECL(memcmp
, (const void *, const void *, size_t));
340 E
void *FDECL(memcpy
, (void *, const void *, size_t));
341 E
void *FDECL(memset
, (void *, int, size_t));
343 E
int FDECL(memcmp
, (char *, char *, unsigned int));
344 E
char *FDECL(memcpy
, (char *, char *, unsigned int));
345 E
char *FDECL(memset
, (char *, int, int));
346 #endif /* AZTEC_50 || NHSTDC */
350 #if defined(BSD) && defined(ultrix) /* i.e., old versions of Ultrix */
353 #if defined(ULTRIX) || defined(SYSV)
357 E
unsigned int FDECL(sleep
, (unsigned int));
360 E
int FDECL(sleep
, (unsigned));
363 E
char *FDECL(getenv
, (const char *));
365 #if defined(HPUX) && !defined(_POSIX_SOURCE)
366 E
long NDECL(getuid
);
367 E
long NDECL(getgid
);
368 E
long NDECL(getpid
);
371 E pid_t
NDECL(getpid
);
372 E uid_t
NDECL(getuid
);
373 E gid_t
NDECL(getgid
);
375 E pid_t
NDECL(getppid
);
377 #else /*!POSIX_TYPES*/
378 #ifndef getpid /* Borland C defines getpid() as a macro */
382 E
int NDECL(getppid
);
383 E
unsigned NDECL(getuid
);
384 E
unsigned NDECL(getgid
);
386 #if defined(ULTRIX) && !defined(_UNISTD_H_)
387 E
unsigned NDECL(getuid
);
388 E
unsigned NDECL(getgid
);
389 E
int FDECL(setgid
, (int));
390 E
int FDECL(setuid
, (int));
392 #endif /*?POSIX_TYPES*/
393 #endif /*?(HPUX && !_POSIX_SOURCE)*/
395 /* add more architectures as needed */
397 #define seteuid(x) setreuid(-1, (x));
401 #if !defined(_XtIntrinsic_h) && !defined(POSIX_TYPES)
402 /* <X11/Intrinsic.h> #includes <string[s].h>; so does defining POSIX_TYPES */
404 #if (defined(ULTRIX) || defined(NeXT)) && defined(__GNUC__)
407 E
char *FDECL(strcpy
, (char *, const char *));
408 E
char *FDECL(strncpy
, (char *, const char *, size_t));
409 E
char *FDECL(strcat
, (char *, const char *));
410 E
char *FDECL(strncat
, (char *, const char *, size_t));
411 E
char *FDECL(strpbrk
, (const char *, const char *));
413 #if defined(SYSV) || defined(MICRO) || defined(MAC) || defined(VMS) \
415 E
char *FDECL(strchr
, (const char *, int));
416 E
char *FDECL(strrchr
, (const char *, int));
418 E
char *FDECL(index
, (const char *, int));
419 E
char *FDECL(rindex
, (const char *, int));
422 E
int FDECL(strcmp
, (const char *, const char *));
423 E
int FDECL(strncmp
, (const char *, const char *, size_t));
424 #if defined(MICRO) || defined(MAC) || defined(VMS)
425 E
size_t FDECL(strlen
, (const char *));
428 E
unsigned int FDECL(strlen
, (char *));
430 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
431 E
int FDECL(strlen
, (const char *));
437 #endif /* !_XtIntrinsic_h_ && !POSIX_TYPES */
439 #if defined(ULTRIX) && defined(__GNUC__)
440 E
char *FDECL(index
, (const char *, int));
441 E
char *FDECL(rindex
, (const char *, int));
444 /* Old varieties of BSD have char *sprintf().
445 * Newer varieties of BSD have int sprintf() but allow for the old char *.
446 * Several varieties of SYSV and PC systems also have int sprintf().
447 * If your system doesn't agree with this breakdown, you may want to change
448 * this declaration, especially if your machine treats the types differently.
449 * If your system defines sprintf, et al, in stdio.h, add to the initial
452 #if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || defined(WIN32)
453 #define SPRINTF_PROTO
455 #if (defined(SUNOS4) && defined(__STDC__)) || defined(_AIX32)
456 #define SPRINTF_PROTO
458 #if defined(TOS) || defined(AZTEC_50) || defined(__sgi) || defined(__GNUC__)
459 /* problem with prototype mismatches */
460 #define SPRINTF_PROTO
462 #if defined(__MWERKS__) || defined(__SC__)
463 /* Metrowerks already has a prototype for sprintf() */
464 #define SPRINTF_PROTO
467 #ifndef SPRINTF_PROTO
468 #if defined(POSIX_TYPES) || defined(DGUX) || defined(NeXT) || !defined(BSD)
469 E
int FDECL(sprintf
, (char *, const char *, ...));
481 #if defined(USE_STDARG) || defined(USE_VARARGS)
482 #if !defined(SVR4) && !defined(apollo)
483 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
484 #if !(defined(SUNOS4) && defined(__STDC__)) /* Solaris unbundled cc (acc) */
485 E
int FDECL(vsprintf
, (char *, const char *, va_list));
486 E
int FDECL(vfprintf
, (FILE *, const char *, va_list));
487 E
int FDECL(vprintf
, (const char *, va_list));
492 #define vprintf printf
493 #define vfprintf fprintf
494 #define vsprintf sprintf
496 #endif /* NEED_VARARGS */
500 E
int FDECL(tgetent
, (const char *, const char *));
501 E
void FDECL(tputs
, (const char *, int, int (*)()));
502 E
int FDECL(tgetnum
, (const char *));
503 E
int FDECL(tgetflag
, (const char *));
504 E
char *FDECL(tgetstr
, (const char *, char **));
505 E
char *FDECL(tgoto
, (const char *, int, int));
507 #if !(defined(HPUX) && defined(_POSIX_SOURCE))
508 E
int FDECL(tgetent
, (char *, const char *));
509 E
void FDECL(tputs
, (const char *, int, int (*)()));
511 E
int FDECL(tgetnum
, (const char *));
512 E
int FDECL(tgetflag
, (const char *));
513 E
char *FDECL(tgetstr
, (const char *, char **));
514 E
char *FDECL(tgoto
, (const char *, int, int));
517 #if defined(ALLOC_C) || defined(MAKEDEFS_C)
518 E genericptr_t
FDECL(malloc
, (size_t));
519 E genericptr_t
FDECL(realloc
, (genericptr_t
, size_t));
525 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
526 E
struct tm
*FDECL(localtime
, (const time_t *));
530 #if defined(ULTRIX) || (defined(BSD) && defined(POSIX_TYPES)) \
531 || defined(SYSV) || defined(MICRO) || defined(VMS) || defined(MAC) \
532 || (defined(HPUX) && defined(_POSIX_SOURCE))
533 E
time_t FDECL(time
, (time_t *));
535 E
long FDECL(time
, (time_t *));
539 /* used in makedefs.c, but missing from gcc-vms's <time.h> */
540 E
char *FDECL(ctime
, (const time_t *));
547 E
int FDECL(abs
, (int));
551 E
int FDECL(atoi
, (const char *));
556 #endif /* !__cplusplus && !__GO32__ */
558 #endif /* SYSTEM_H */