Couple of extra nethack->anethack
[aNetHack.git] / include / system.h
bloba700ce6379fa0df3945ccbb3fec4705ea6609d0c
1 /* aNetHack 0.0.1 system.h $ANH-Date: 1449269772 2015/12/04 22:56:12 $ $ANH-Branch: master $:$ANH-Revision: 1.12 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* aNetHack may be freely redistributed. See license for details. */
5 #ifndef SYSTEM_H
6 #define SYSTEM_H
8 #if !defined(__cplusplus) && !defined(__GO32__)
10 #define E extern
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)
16 #include <types.h>
17 #else
18 #ifndef AMIGA
19 #include <sys/types.h>
20 #endif
21 #endif
23 #if (defined(MICRO) && !defined(TOS)) || defined(ANCIENT_VAXC)
24 #if !defined(_SIZE_T) && !defined(__size_t) /* __size_t for CSet/2 */
25 #define _SIZE_T
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;
30 #endif
31 #endif
32 #endif
33 #endif /* MICRO && !TOS */
35 #if defined(__TURBOC__) || defined(MAC)
36 #include <time.h> /* time_t is not in <sys/types.h> */
37 #endif
38 #if defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC))
39 /* The Ultrix v3.0 <sys/types.h> seems to be very wrong. */
40 #define time_t long
41 #endif
43 #if defined(ULTRIX) || defined(VMS)
44 #define off_t long
45 #endif
46 #if defined(AZTEC) || defined(THINKC4) || defined(__TURBOC__)
47 typedef long off_t;
48 #endif
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)
59 #endif
60 #ifndef SIG_RET_TYPE
61 #if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(__DECC)
62 #define SIG_RET_TYPE void (*)()
63 #endif
64 #endif
65 #ifndef SIG_RET_TYPE
66 #if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4)
67 /* SVR3 is defined automatically by some systems */
68 #define SIG_RET_TYPE void (*)()
69 #endif
70 #endif
71 #ifndef SIG_RET_TYPE /* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */
72 #define SIG_RET_TYPE int (*)()
73 #endif
75 #if !defined(__cplusplus) && !defined(__GO32__)
77 #if defined(BSD) || defined(ULTRIX) || defined(RANDOM)
78 #ifdef random
79 #undef random
80 #endif
81 #if !defined(__SC__) && !defined(LINUX)
82 E long NDECL(random);
83 #endif
84 #if (!defined(SUNOS4) && !defined(bsdi) && !defined(__FreeBSD__)) \
85 || defined(RANDOM)
86 E void FDECL(srandom, (unsigned int));
87 #else
88 #if !defined(bsdi) && !defined(__FreeBSD__)
89 E int FDECL(srandom, (unsigned int));
90 #endif
91 #endif
92 #else
93 E long lrand48();
94 E void srand48();
95 #endif /* BSD || ULTRIX || RANDOM */
97 #if !defined(BSD) || defined(ultrix)
98 /* real BSD wants all these to return int */
99 #ifndef MICRO
100 E void FDECL(exit, (int));
101 #endif /* MICRO */
102 /* compensate for some CSet/2 bogosities */
103 #if defined(OS2_CSET2) && defined(OS2_CSET2_VER_2)
104 #define open _open
105 #define close _close
106 #define read _read
107 #define write _write
108 #define lseek _lseek
109 #define chdir _chdir
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)
117 #ifndef OS2_CSET2
118 #ifndef MONITOR_HEAP
119 E void FDECL(free, (genericptr_t));
120 #endif
121 #endif
122 #endif
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 *));
126 #else
127 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
128 E void FDECL(perror, (const char *));
129 #endif
130 #endif
131 #endif
132 #endif
133 #ifndef NeXT
134 #ifdef POSIX_TYPES
135 E void FDECL(qsort, (genericptr_t, size_t, size_t,
136 int (*)(const genericptr, const genericptr)));
137 #else
138 #if defined(BSD) || defined(ULTRIX)
139 E int qsort();
140 #else
141 #if !defined(LATTICE) && !defined(AZTEC_50)
142 E void FDECL(qsort, (genericptr_t, size_t, size_t,
143 int (*)(const genericptr, const genericptr)));
144 #endif
145 #endif
146 #endif
147 #endif /* NeXT */
149 #ifndef __SASC_60
150 #if !defined(AZTEC_50) && !defined(__GNUC__)
151 /* may already be defined */
153 #ifdef ULTRIX
154 #ifdef ULTRIX_PROTO
155 E int FDECL(lseek, (int, off_t, int));
156 #else
157 E long FDECL(lseek, (int, off_t, int));
158 #endif
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 *));
162 #else
163 #ifndef bsdi
164 E long FDECL(lseek, (int, long, int));
165 #endif
166 #if defined(POSIX_TYPES) || defined(__TURBOC__)
167 #ifndef bsdi
168 E int FDECL(write, (int, const void *, unsigned));
169 #endif
170 #else
171 #ifndef __MWERKS__ /* metrowerks defines write via universal headers */
172 E int FDECL(write, (int, genericptr_t, unsigned));
173 #endif
174 #endif
175 #endif /* ULTRIX */
177 #ifdef OS2_CSET2 /* IBM CSet/2 */
178 #ifdef OS2_CSET2_VER_1
179 E int FDECL(unlink, (char *));
180 #else
181 E int FDECL(unlink, (const char *)); /* prototype is ok in ver >= 2 */
182 #endif
183 #else
184 #ifndef __SC__
185 E int FDECL(unlink, (const char *));
186 #endif
187 #endif
189 #endif /* AZTEC_50 && __GNUC__ */
191 #ifdef MAC
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 */
197 #endif
199 E int FDECL(open, (const char *, int));
200 #endif
202 #if defined(MICRO)
203 E int FDECL(close, (int));
204 #ifndef __EMX__
205 E int FDECL(read, (int, genericptr_t, unsigned int));
206 #endif
207 E int FDECL(open, (const char *, int, ...));
208 E int FDECL(dup2, (int, int));
209 E int FDECL(setmode, (int, int));
210 E int NDECL(kbhit);
211 #if !defined(_DCC)
212 #if defined(__TURBOC__)
213 E int FDECL(chdir, (const char *));
214 #else
215 #ifndef __EMX__
216 E int FDECL(chdir, (char *));
217 #endif
218 #endif
219 #ifndef __EMX__
220 E char *FDECL(getcwd, (char *, int));
221 #endif
222 #endif /* !_DCC */
223 #endif
225 #ifdef ULTRIX
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));
233 #endif
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__)
242 E int NDECL(fork);
243 #else
244 E long NDECL(fork);
245 #endif
246 #endif /* ULTRIX */
248 #ifdef VMS
249 #ifndef abs
250 E int FDECL(abs, (int));
251 #endif
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));
257 #ifdef __DECC_VER
258 E int FDECL(chmod, (const char *, mode_t));
259 E mode_t FDECL(umask, (mode_t));
260 #else
261 E int FDECL(chmod, (const char *, int));
262 E int FDECL(umask, (int));
263 #endif
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));
276 #endif
278 #endif /* __SASC_60 */
280 /* both old & new versions of Ultrix want these, but real BSD does not */
281 #ifdef ultrix
282 E void abort();
283 E void bcopy();
284 #ifdef ULTRIX
285 E int FDECL(system, (const char *));
286 #ifndef _UNISTD_H_
287 E int FDECL(execl, (const char *, ...));
288 #endif
289 #endif
290 #endif
291 #ifdef MICRO
292 E void NDECL(abort);
293 E void FDECL(_exit, (int));
294 E int FDECL(system, (const char *));
295 #endif
296 #if defined(HPUX) && !defined(_POSIX_SOURCE)
297 E long NDECL(fork);
298 #endif
300 #ifdef POSIX_TYPES
301 /* The POSIX string.h is required to define all the mem* and str* functions */
302 #include <string.h>
303 #else
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));
311 #endif
312 #else
313 #ifndef memcmp /* some systems seem to macro these back to b*() */
314 E int memcmp();
315 #endif
316 #ifndef memcpy
317 E char *memcpy();
318 #endif
319 #ifndef memset
320 E char *memset();
321 #endif
322 #endif
323 #else
324 #ifdef HPUX
325 E int FDECL(memcmp, (char *, char *, int));
326 E void *FDECL(memcpy, (char *, char *, int));
327 E void *FDECL(memset, (char *, int, int));
328 #endif
329 #endif
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));
337 #else
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));
342 #else
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 */
347 #endif /* TOS */
348 #endif /* MICRO */
350 #if defined(BSD) && defined(ultrix) /* i.e., old versions of Ultrix */
351 E void sleep();
352 #endif
353 #if defined(ULTRIX) || defined(SYSV)
354 E unsigned sleep();
355 #endif
356 #if defined(HPUX)
357 E unsigned int FDECL(sleep, (unsigned int));
358 #endif
359 #ifdef VMS
360 E int FDECL(sleep, (unsigned));
361 #endif
363 E char *FDECL(getenv, (const char *));
364 E char *getlogin();
365 #if defined(HPUX) && !defined(_POSIX_SOURCE)
366 E long NDECL(getuid);
367 E long NDECL(getgid);
368 E long NDECL(getpid);
369 #else
370 #ifdef POSIX_TYPES
371 E pid_t NDECL(getpid);
372 E uid_t NDECL(getuid);
373 E gid_t NDECL(getgid);
374 #ifdef VMS
375 E pid_t NDECL(getppid);
376 #endif
377 #else /*!POSIX_TYPES*/
378 #ifndef getpid /* Borland C defines getpid() as a macro */
379 E int NDECL(getpid);
380 #endif
381 #ifdef VMS
382 E int NDECL(getppid);
383 E unsigned NDECL(getuid);
384 E unsigned NDECL(getgid);
385 #endif
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));
391 #endif
392 #endif /*?POSIX_TYPES*/
393 #endif /*?(HPUX && !_POSIX_SOURCE)*/
395 /* add more architectures as needed */
396 #if defined(HPUX)
397 #define seteuid(x) setreuid(-1, (x));
398 #endif
400 /*# string(s).h #*/
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__)
405 #include <strings.h>
406 #else
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) \
414 || defined(HPUX)
415 E char *FDECL(strchr, (const char *, int));
416 E char *FDECL(strrchr, (const char *, int));
417 #else /* BSD */
418 E char *FDECL(index, (const char *, int));
419 E char *FDECL(rindex, (const char *, int));
420 #endif
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 *));
426 #else
427 #ifdef HPUX
428 E unsigned int FDECL(strlen, (char *));
429 #else
430 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
431 E int FDECL(strlen, (const char *));
432 #endif
433 #endif /* HPUX */
434 #endif /* MICRO */
435 #endif /* ULTRIX */
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));
442 #endif
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
450 * #if.
452 #if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || defined(WIN32)
453 #define SPRINTF_PROTO
454 #endif
455 #if (defined(SUNOS4) && defined(__STDC__)) || defined(_AIX32)
456 #define SPRINTF_PROTO
457 #endif
458 #if defined(TOS) || defined(AZTEC_50) || defined(__sgi) || defined(__GNUC__)
459 /* problem with prototype mismatches */
460 #define SPRINTF_PROTO
461 #endif
462 #if defined(__MWERKS__) || defined(__SC__)
463 /* Metrowerks already has a prototype for sprintf() */
464 #define SPRINTF_PROTO
465 #endif
467 #ifndef SPRINTF_PROTO
468 #if defined(POSIX_TYPES) || defined(DGUX) || defined(NeXT) || !defined(BSD)
469 E int FDECL(sprintf, (char *, const char *, ...));
470 #else
471 #define OLD_SPRINTF
472 E char *sprintf();
473 #endif
474 #endif
475 #ifdef SPRINTF_PROTO
476 #undef SPRINTF_PROTO
477 #endif
479 #ifndef __SASC_60
480 #ifdef NEED_VARARGS
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));
488 #endif
489 #endif
490 #endif
491 #else
492 #define vprintf printf
493 #define vfprintf fprintf
494 #define vsprintf sprintf
495 #endif
496 #endif /* NEED_VARARGS */
497 #endif
499 #ifdef MICRO
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));
506 #else
507 #if !(defined(HPUX) && defined(_POSIX_SOURCE))
508 E int FDECL(tgetent, (char *, const char *));
509 E void FDECL(tputs, (const char *, int, int (*)()));
510 #endif
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));
515 #endif
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));
520 #endif
522 /* time functions */
524 #ifndef LATTICE
525 #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
526 E struct tm *FDECL(localtime, (const time_t *));
527 #endif
528 #endif
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 *));
534 #else
535 E long FDECL(time, (time_t *));
536 #endif /* ULTRIX */
538 #ifdef VMS
539 /* used in makedefs.c, but missing from gcc-vms's <time.h> */
540 E char *FDECL(ctime, (const time_t *));
541 #endif
543 #ifdef MICRO
544 #ifdef abs
545 #undef abs
546 #endif
547 E int FDECL(abs, (int));
548 #ifdef atoi
549 #undef atoi
550 #endif
551 E int FDECL(atoi, (const char *));
552 #endif
554 #undef E
556 #endif /* !__cplusplus && !__GO32__ */
558 #endif /* SYSTEM_H */