OSDN Git Service

add readme for 3.6
[jnethack/source.git] / util / panic.c
1 /* NetHack 3.6  panic.c $NHDT-Date: 1448210012 2015/11/22 16:33:32 $  $NHDT-Branch: master $:$NHDT-Revision: 1.10 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 /*
6  *      This code was adapted from the code in end.c to run in a standalone
7  *      mode for the makedefs / drg code.
8  */
9
10 #define NEED_VARARGS
11 #include "config.h"
12
13 #ifdef AZTEC
14 #define abort() exit()
15 #endif
16 #ifdef VMS
17 extern void NDECL(vms_abort);
18 #endif
19
20 /*VARARGS1*/
21 boolean panicking;
22 void VDECL(panic, (char *, ...));
23
24 void panic
25 VA_DECL(char *, str)
26 {
27     VA_START(str);
28     VA_INIT(str, char *);
29     if (panicking++)
30 #ifdef SYSV
31         (void)
32 #endif
33             abort(); /* avoid loops - this should never happen*/
34
35     (void) fputs(" ERROR:  ", stderr);
36     Vfprintf(stderr, str, VA_ARGS);
37     (void) fflush(stderr);
38 #if defined(UNIX) || defined(VMS)
39 #ifdef SYSV
40     (void)
41 #endif
42         abort(); /* generate core dump */
43 #endif
44     VA_END();
45     exit(EXIT_FAILURE); /* redundant */
46 }
47
48 #ifdef ALLOCA_HACK
49 /*
50  * In case bison-generated foo_yacc.c tries to use alloca(); if we don't
51  * have it then just use malloc() instead.  This may not work on some
52  * systems, but they should either use yacc or get a real alloca routine.
53  */
54 long *
55 alloca(cnt)
56 unsigned cnt;
57 {
58     return cnt ? alloc(cnt) : (long *) 0;
59 }
60 #endif
61
62 /*panic.c*/