1
/* -----------------------------------------------------------------------------
3
* (c) The GHC Team, 1998-2009
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
10
* Do not #include this file directly: #include "Rts.h" instead.
12
* To understand the structure of the RTS headers, see the wiki:
13
* http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
15
* ---------------------------------------------------------------------------*/
17
#ifndef RTS_MESSAGES_H
18
#define RTS_MESSAGES_H
22
/* -----------------------------------------------------------------------------
24
* -------------------------------------------------------------------------- */
27
* A fatal internal error: this is for errors that probably indicate
28
* bugs in the RTS or compiler. We normally output bug reporting
29
* instructions along with the error message.
31
* barf() invokes (*fatalInternalErrorFn)(). This function is not
34
void barf(const char *s, ...)
35
GNUC3_ATTRIBUTE(__noreturn__);
37
void vbarf(const char *s, va_list ap)
38
GNUC3_ATTRIBUTE(__noreturn__);
41
// extern void _assertFail(const char *filename, unsigned int linenum)
42
// GNUC3_ATTRIBUTE(__noreturn__);
45
* An error condition which is caused by and/or can be corrected by
48
* errorBelch() invokes (*errorMsgFn)().
50
void errorBelch(const char *s, ...)
51
GNUC3_ATTRIBUTE(format (printf, 1, 2));
53
void verrorBelch(const char *s, va_list ap);
56
* An error condition which is caused by and/or can be corrected by
57
* the user, and which has an associated error condition reported
58
* by the system (in errno on Unix, and GetLastError() on Windows).
59
* The system error message is appended to the message generated
60
* from the supplied format string.
62
* sysErrorBelch() invokes (*sysErrorMsgFn)().
64
void sysErrorBelch(const char *s, ...)
65
GNUC3_ATTRIBUTE(format (printf, 1, 2));
67
void vsysErrorBelch(const char *s, va_list ap);
70
* A debugging message. Debugging messages are generated either as a
71
* virtue of having DEBUG turned on, or by being explicitly selected
72
* via RTS options (eg. +RTS -Ds).
74
* debugBelch() invokes (*debugMsgFn)().
76
void debugBelch(const char *s, ...)
77
GNUC3_ATTRIBUTE(format (printf, 1, 2));
79
void vdebugBelch(const char *s, va_list ap);
82
/* Hooks for redirecting message generation: */
84
typedef void RtsMsgFunction(const char *, va_list);
86
extern RtsMsgFunction *fatalInternalErrorFn;
87
extern RtsMsgFunction *debugMsgFn;
88
extern RtsMsgFunction *errorMsgFn;
90
/* Default stdio implementation of the message hooks: */
92
extern RtsMsgFunction rtsFatalInternalErrorFn;
93
extern RtsMsgFunction rtsDebugMsgFn;
94
extern RtsMsgFunction rtsErrorMsgFn;
95
extern RtsMsgFunction rtsSysErrorMsgFn;
97
#endif /* RTS_MESSAGES_H */