Source:NetHack 3.6.5/include/system.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to system.h from the source code of NetHack 3.6.5. To link to a particular line, write [[Source:NetHack 3.6.5/include/system.h#line12]], for example.

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

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. */
5. 
6. #ifndef SYSTEM_H
7. #define SYSTEM_H
8. 
9. #if !defined(__cplusplus) && !defined(__GO32__)
10. 
11. #define E extern
12. 
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
15.  */
16. #if (defined(VMS) && !defined(__GNUC__)) || defined(MAC)
17. #include <types.h>
18. #else
19. #ifndef AMIGA
20. #include <sys/types.h>
21. #endif
22. #endif
23. 
24. #if (defined(MICRO) && !defined(TOS)) || defined(ANCIENT_VAXC)
25. #if !defined(_SIZE_T) && !defined(__size_t) /* __size_t for CSet/2 */
26. #define _SIZE_T
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;
31. #endif
32. #endif
33. #endif
34. #endif /* MICRO && !TOS */
35. 
36. #if defined(__TURBOC__) || defined(MAC)
37. #include <time.h> /* time_t is not in <sys/types.h> */
38. #endif
39. #if defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC))
40. /* The Ultrix v3.0 <sys/types.h> seems to be very wrong. */
41. #define time_t long
42. #endif
43. 
44. #if defined(ULTRIX) || defined(VMS)
45. #define off_t long
46. #endif
47. #if defined(AZTEC) || defined(THINKC4) || defined(__TURBOC__)
48. typedef long off_t;
49. #endif
50. 
51. #endif /* !__cplusplus && !__GO32__ */
52. 
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.
56.  */
57. #if !defined(OS2) && (defined(_MSC_VER) || defined(__TURBOC__) \
58.                       || defined(__SC__) || defined(WIN32))
59. #define SIG_RET_TYPE void(__cdecl *)(int)
60. #endif
61. #ifndef SIG_RET_TYPE
62. #if defined(NHSTDC) || defined(POSIX_TYPES) || defined(OS2) || defined(__DECC)
63. #define SIG_RET_TYPE void (*)()
64. #endif
65. #endif
66. #ifndef SIG_RET_TYPE
67. #if defined(ULTRIX) || defined(SUNOS4) || defined(SVR3) || defined(SVR4)
68. /* SVR3 is defined automatically by some systems */
69. #define SIG_RET_TYPE void (*)()
70. #endif
71. #endif
72. #ifndef SIG_RET_TYPE /* BSD, SIII, SVR2 and earlier, Sun3.5 and earlier */
73. #define SIG_RET_TYPE int (*)()
74. #endif
75. 
76. #if !defined(__cplusplus) && !defined(__GO32__)
77. 
78. #if defined(BSD) || defined(ULTRIX) || defined(RANDOM)
79. #ifdef random
80. #undef random
81. #endif
82. #if !defined(__SC__) && !defined(LINUX)
83. E long NDECL(random);
84. #endif
85. #if (!defined(SUNOS4) && !defined(bsdi) && !defined(__FreeBSD__)) \
86.     || defined(RANDOM)
87. E void FDECL(srandom, (unsigned int));
88. #else
89. #if !defined(bsdi) && !defined(__FreeBSD__)
90. E int FDECL(srandom, (unsigned int));
91. #endif
92. #endif
93. #else
94. #if defined(MACOSX)
95. E long NDECL(lrand48);
96. E void FDECL(srand48, (long));
97. #else
98. E long lrand48();
99. E void srand48();
100. #endif /* MACOSX */
101. #endif /* BSD || ULTRIX || RANDOM */
102. 
103. #if !defined(BSD) || defined(ultrix)
104. /* real BSD wants all these to return int */
105. #ifndef MICRO
106. E void FDECL(exit, (int));
107. #endif /* MICRO */
108. /* compensate for some CSet/2 bogosities */
109. #if defined(OS2_CSET2) && defined(OS2_CSET2_VER_2)
110. #define open _open
111. #define close _close
112. #define read _read
113. #define write _write
114. #define lseek _lseek
115. #define chdir _chdir
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)
123. #ifndef OS2_CSET2
124. #ifndef MONITOR_HEAP
125. E void FDECL(free, (genericptr_t));
126. #endif
127. #endif
128. #endif
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 *));
132. #else
133. #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
134. E void FDECL(perror, (const char *));
135. #endif
136. #endif
137. #endif
138. #endif
139. #ifndef NeXT
140. #ifdef POSIX_TYPES
141. E void FDECL(qsort, (genericptr_t, size_t, size_t,
142.                      int (*)(const genericptr, const genericptr)));
143. #else
144. #if defined(BSD) || defined(ULTRIX)
145. E int qsort();
146. #else
147. #if !defined(LATTICE) && !defined(AZTEC_50)
148. E void FDECL(qsort, (genericptr_t, size_t, size_t,
149.                      int (*)(const genericptr, const genericptr)));
150. #endif
151. #endif
152. #endif
153. #endif /* NeXT */
154. 
155. #ifndef __SASC_60
156. #if !defined(AZTEC_50) && !defined(__GNUC__)
157. /* may already be defined */
158. 
159. #ifdef ULTRIX
160. #ifdef ULTRIX_PROTO
161. E int FDECL(lseek, (int, off_t, int));
162. #else
163. E long FDECL(lseek, (int, off_t, int));
164. #endif
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 *));
168. #else /*!ULTRIX*/
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));
173. #else
174. #ifndef __MWERKS__ /* metrowerks defines write via universal headers */
175. E int FDECL(write, (int, genericptr_t, unsigned));
176. #endif
177. #endif /*?(POSIX_TYPES || __TURBOC__)*/
178. #endif /*!(bsdi || VMS)*/
179. #endif /*?ULTRIX*/
180. 
181. #ifdef OS2_CSET2 /* IBM CSet/2 */
182. #ifdef OS2_CSET2_VER_1
183. E int FDECL(unlink, (char *));
184. #else
185. E int FDECL(unlink, (const char *)); /* prototype is ok in ver >= 2 */
186. #endif
187. #else
188. #ifndef __SC__
189. E int FDECL(unlink, (const char *));
190. #endif
191. #endif
192. 
193. #endif /* AZTEC_50 && __GNUC__ */
194. 
195. #ifdef MAC
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 */
201. #endif
202. 
203. E int FDECL(open, (const char *, int));
204. #endif
205. 
206. #if defined(MICRO)
207. E int FDECL(close, (int));
208. #ifndef __EMX__
209. E int FDECL(read, (int, genericptr_t, unsigned int));
210. #endif
211. E int FDECL(open, (const char *, int, ...));
212. E int FDECL(dup2, (int, int));
213. E int FDECL(setmode, (int, int));
214. E int NDECL(kbhit);
215. #if !defined(_DCC)
216. #if defined(__TURBOC__)
217. E int FDECL(chdir, (const char *));
218. #else
219. #ifndef __EMX__
220. E int FDECL(chdir, (char *));
221. #endif
222. #endif
223. #ifndef __EMX__
224. E char *FDECL(getcwd, (char *, int));
225. #endif
226. #endif /* !_DCC */
227. #endif
228. 
229. #ifdef ULTRIX
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));
237. #endif
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__)
246. E int NDECL(fork);
247. #else
248. E long NDECL(fork);
249. #endif
250. #endif /* ULTRIX */
251. 
252. #ifdef VMS
253. #ifndef abs
254. E int FDECL(abs, (int));
255. #endif
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));
261. #ifdef __DECC_VER
262. E int FDECL(chmod, (const char *, mode_t));
263. E mode_t FDECL(umask, (mode_t));
264. #else
265. E int FDECL(chmod, (const char *, int));
266. E int FDECL(umask, (int));
267. #endif
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));
280. #endif
281. 
282. #endif /* __SASC_60 */
283. 
284. /* both old & new versions of Ultrix want these, but real BSD does not */
285. #ifdef ultrix
286. E void abort();
287. E void bcopy();
288. #ifdef ULTRIX
289. E int FDECL(system, (const char *));
290. #ifndef _UNISTD_H_
291. E int FDECL(execl, (const char *, ...));
292. #endif
293. #endif
294. #endif
295. #ifdef MICRO
296. E void NDECL(abort);
297. E void FDECL(_exit, (int));
298. E int FDECL(system, (const char *));
299. #endif
300. #if defined(HPUX) && !defined(_POSIX_SOURCE)
301. E long NDECL(fork);
302. #endif
303. 
304. #ifdef POSIX_TYPES
305. /* The POSIX string.h is required to define all the mem* and str* functions */
306. #include <string.h>
307. #else
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));
315. #endif
316. #else
317. #ifndef memcmp /* some systems seem to macro these back to b*() */
318. E int memcmp();
319. #endif
320. #ifndef memcpy
321. E char *memcpy();
322. #endif
323. #ifndef memset
324. E char *memset();
325. #endif
326. #endif
327. #else
328. #ifdef HPUX
329. E int FDECL(memcmp, (char *, char *, int));
330. E void *FDECL(memcpy, (char *, char *, int));
331. E void *FDECL(memset, (char *, int, int));
332. #endif
333. #endif
334. #endif /* POSIX_TYPES */
335. 
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));
341. #else
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));
346. #else
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 */
351. #endif /* TOS */
352. #endif /* MICRO */
353. 
354. #if defined(BSD) && defined(ultrix) /* i.e., old versions of Ultrix */
355. E void sleep();
356. #endif
357. #if defined(ULTRIX) || defined(SYSV)
358. E unsigned sleep();
359. #endif
360. #if defined(HPUX)
361. E unsigned int FDECL(sleep, (unsigned int));
362. #endif
363. #ifdef VMS
364. E int FDECL(sleep, (unsigned));
365. #endif
366. 
367. E char *FDECL(getenv, (const char *));
368. E char *getlogin();
369. #if defined(HPUX) && !defined(_POSIX_SOURCE)
370. E long NDECL(getuid);
371. E long NDECL(getgid);
372. E long NDECL(getpid);
373. #else
374. #ifdef POSIX_TYPES
375. E pid_t NDECL(getpid);
376. E uid_t NDECL(getuid);
377. E gid_t NDECL(getgid);
378. #ifdef VMS
379. E pid_t NDECL(getppid);
380. #endif
381. #else          /*!POSIX_TYPES*/
382. #ifndef getpid /* Borland C defines getpid() as a macro */
383. E int NDECL(getpid);
384. #endif
385. #ifdef VMS
386. E int NDECL(getppid);
387. E unsigned NDECL(getuid);
388. E unsigned NDECL(getgid);
389. #endif
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));
395. #endif
396. #endif /*?POSIX_TYPES*/
397. #endif /*?(HPUX && !_POSIX_SOURCE)*/
398. 
399. /* add more architectures as needed */
400. #if defined(HPUX)
401. #define seteuid(x) setreuid(-1, (x));
402. #endif
403. 
404. /*# string(s).h #*/
405. #if !defined(_XtIntrinsic_h) && !defined(POSIX_TYPES)
406. /* <X11/Intrinsic.h> #includes <string[s].h>; so does defining POSIX_TYPES */
407. 
408. #if (defined(ULTRIX) || defined(NeXT)) && defined(__GNUC__)
409. #include <strings.h>
410. #else
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 *));
416. 
417. #if defined(SYSV) || defined(MICRO) || defined(MAC) || defined(VMS) \
418.     || defined(HPUX)
419. E char *FDECL(strchr, (const char *, int));
420. E char *FDECL(strrchr, (const char *, int));
421. #else /* BSD */
422. E char *FDECL(index, (const char *, int));
423. E char *FDECL(rindex, (const char *, int));
424. #endif
425. 
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 *));
430. #else
431. #ifdef HPUX
432. E unsigned int FDECL(strlen, (char *));
433. #else
434. #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
435. E int FDECL(strlen, (const char *));
436. #endif
437. #endif /* HPUX */
438. #endif /* MICRO */
439. #endif /* ULTRIX */
440. 
441. #endif /* !_XtIntrinsic_h_ && !POSIX_TYPES */
442. 
443. #if defined(ULTRIX) && defined(__GNUC__)
444. E char *FDECL(index, (const char *, int));
445. E char *FDECL(rindex, (const char *, int));
446. #endif
447. 
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
454.  * #if.
455.  */
456. #if defined(ULTRIX) || defined(__DECC) || defined(__SASC_60) || defined(WIN32)
457. #define SPRINTF_PROTO
458. #endif
459. #if (defined(SUNOS4) && defined(__STDC__)) || defined(_AIX32)
460. #define SPRINTF_PROTO
461. #endif
462. #if defined(TOS) || defined(AZTEC_50) || defined(__sgi) || defined(__GNUC__)
463. /* problem with prototype mismatches */
464. #define SPRINTF_PROTO
465. #endif
466. #if defined(__MWERKS__) || defined(__SC__)
467. /* Metrowerks already has a prototype for sprintf() */
468. #define SPRINTF_PROTO
469. #endif
470. 
471. #ifndef SPRINTF_PROTO
472. #if defined(POSIX_TYPES) || defined(DGUX) || defined(NeXT) || !defined(BSD)
473. E int FDECL(sprintf, (char *, const char *, ...));
474. #else
475. #define OLD_SPRINTF
476. E char *sprintf();
477. #endif
478. #endif
479. #ifdef SPRINTF_PROTO
480. #undef SPRINTF_PROTO
481. #endif
482. 
483. #ifndef __SASC_60
484. #ifdef NEED_VARARGS
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));
492. #endif
493. #endif
494. #endif
495. #else
496. #ifdef vprintf
497. #undef vprintf
498. #endif
499. #define vprintf printf
500. #ifdef vfprintf
501. #undef vfprintf
502. #endif
503. #define vfprintf fprintf
504. #ifdef vsprintf
505. #undef vsprintf
506. #endif
507. #define vsprintf sprintf
508. #endif
509. #endif /* NEED_VARARGS */
510. #endif
511. 
512. #ifdef MICRO
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));
519. #else
520. #if !(defined(HPUX) && defined(_POSIX_SOURCE))
521. E int FDECL(tgetent, (char *, const char *));
522. E void FDECL(tputs, (const char *, int, int (*)()));
523. #endif
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));
528. #endif
529. 
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));
533. #endif
534. 
535. /* time functions */
536. 
537. #ifndef LATTICE
538. #if !(defined(ULTRIX_PROTO) && defined(__GNUC__))
539. E struct tm *FDECL(localtime, (const time_t *));
540. #endif
541. #endif
542. 
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 *));
547. #else
548. E long FDECL(time, (time_t *));
549. #endif /* ULTRIX */
550. 
551. #ifdef VMS
552. /* used in makedefs.c, but missing from gcc-vms's <time.h> */
553. E char *FDECL(ctime, (const time_t *));
554. #endif
555. 
556. #ifdef MICRO
557. #ifdef abs
558. #undef abs
559. #endif
560. E int FDECL(abs, (int));
561. #ifdef atoi
562. #undef atoi
563. #endif
564. E int FDECL(atoi, (const char *));
565. #endif
566. 
567. #undef E
568. 
569. #endif /*  !__cplusplus && !__GO32__ */
570. 
571. #endif /* SYSTEM_H */