RTS tidyup sweep, first phase
[ghc-hetmet.git] / includes / rts / Messages.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team, 1998-2004
4  *
5  * Message API for use inside the RTS.  All messages generated by the
6  * RTS should go through one of the functions declared here, and we
7  * also provide hooks so that messages from the RTS can be redirected
8  * as appropriate.
9  *
10  * ---------------------------------------------------------------------------*/
11
12 #ifndef RTS_MESSAGES_H
13 #define RTS_MESSAGES_H
14
15 #include <stdarg.h>
16
17 /* -----------------------------------------------------------------------------
18  * Message generation
19  * -------------------------------------------------------------------------- */
20
21 /*
22  * A fatal internal error: this is for errors that probably indicate
23  * bugs in the RTS or compiler.  We normally output bug reporting
24  * instructions along with the error message.
25  *
26  * barf() invokes (*fatalInternalErrorFn)().  This function is not
27  * expected to return.
28  */
29 void barf(const char *s, ...)
30    GNUC3_ATTRIBUTE(__noreturn__);
31
32 void vbarf(const char *s, va_list ap)
33    GNUC3_ATTRIBUTE(__noreturn__);
34
35 // declared in Rts.h:
36 // extern void _assertFail(const char *filename, unsigned int linenum)
37 //    GNUC3_ATTRIBUTE(__noreturn__);
38
39 /*
40  * An error condition which is caused by and/or can be corrected by
41  * the user.
42  *
43  * errorBelch() invokes (*errorMsgFn)().
44  */
45 void errorBelch(const char *s, ...)
46    GNUC3_ATTRIBUTE(format (printf, 1, 2));
47
48 void verrorBelch(const char *s, va_list ap);
49
50 /*
51  * An error condition which is caused by and/or can be corrected by
52  * the user, and which has an associated error condition reported
53  * by the system (in errno on Unix, and GetLastError() on Windows).
54  * The system error message is appended to the message generated
55  * from the supplied format string.
56  *
57  * sysErrorBelch() invokes (*sysErrorMsgFn)().
58  */
59 void sysErrorBelch(const char *s, ...)
60    GNUC3_ATTRIBUTE(format (printf, 1, 2));
61
62 void vsysErrorBelch(const char *s, va_list ap);
63
64 /*
65  * A debugging message.  Debugging messages are generated either as a
66  * virtue of having DEBUG turned on, or by being explicitly selected
67  * via RTS options (eg. +RTS -Ds).
68  *
69  * debugBelch() invokes (*debugMsgFn)().
70  */
71 void debugBelch(const char *s, ...)
72    GNUC3_ATTRIBUTE(format (printf, 1, 2));
73
74 void vdebugBelch(const char *s, va_list ap);
75
76
77 /* Hooks for redirecting message generation: */
78
79 typedef void RtsMsgFunction(const char *, va_list);
80
81 extern RtsMsgFunction *fatalInternalErrorFn;
82 extern RtsMsgFunction *debugMsgFn;
83 extern RtsMsgFunction *errorMsgFn;
84
85 /* Default stdio implementation of the message hooks: */
86
87 extern RtsMsgFunction rtsFatalInternalErrorFn;
88 extern RtsMsgFunction rtsDebugMsgFn;
89 extern RtsMsgFunction rtsErrorMsgFn;
90 extern RtsMsgFunction rtsSysErrorMsgFn;
91
92 #endif /* RTS_MESSAGES_H */