File: error.c

package info (click to toggle)
smlnj-runtime 110.44-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,968 kB
  • ctags: 5,368
  • sloc: ansic: 24,674; asm: 4,195; makefile: 1,353; sh: 91
file content (112 lines) | stat: -rw-r--r-- 1,801 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* error.c
 *
 * COPYRIGHT (c) 1994 by AT&T Bell Laboratories.
 *
 * Run-time system error messages.
 */

#include <stdio.h>
#include <stdarg.h>
#include "ml-base.h"

extern FILE	*DebugF;

#ifdef TARGET_BYTECODE
extern FILE	*BC_stdout;
#endif


/* Say:
 * Print a message to the standard output.
 */
void Say (char *fmt, ...)
{
    va_list	ap;

    va_start (ap, fmt);
    vfprintf (stdout, fmt, ap);
    va_end(ap);
    fflush (stdout);

} /* end of Say */

/* SayDebug:
 * Print a message to the debug output stream.
 */
void SayDebug (char *fmt, ...)
{
    va_list	ap;

    va_start (ap, fmt);
    vfprintf (DebugF, fmt, ap);
    va_end(ap);
    fflush (DebugF);

} /* end of SayDebug */

/* Error:
 * Print an error message.
 */
void Error (char *fmt, ...)
{
    va_list	ap;

    va_start (ap, fmt);
    fprintf (stderr, "%s: Error -- ", MLCmdName);
    vfprintf (stderr, fmt, ap);
    va_end(ap);

} /* end of Error */


/* Die:
 * Print an error message and then exit.
 */
void Die (char *fmt, ...)
{
    va_list	ap;

    va_start (ap, fmt);
    fprintf (stderr, "%s: Fatal error -- ", MLCmdName);
    vfprintf (stderr, fmt, ap);
    fprintf (stderr, "\n");
    va_end(ap);

#if (defined(TARGET_BYTECODE) && defined(INSTR_HISTORY))
    {
	extern void PrintRegs (FILE *);
	extern void PrintInstrHistory (FILE *);

	PrintRegs (BC_stdout);
	PrintInstrHistory (BC_stdout);
    }
#endif

#ifdef MP_SUPPORT
    MP_Shutdown ();
#endif

    Exit (1);

} /* end of Die */


#ifdef ASSERT_ON
/* AssertFail:
 *
 * Print an assertion failure message.
 */
void AssertFail (const char *a, const char *file, int line)
{
    fprintf (stderr, "%s: Assertion failure (%s) at \"%s:%d\"\n",
	MLCmdName, a, file, line);

#ifdef MP_SUPPORT
    MP_Shutdown ();
#endif

    Exit (2);

} /* end of AssertFail */
#endif