1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2004
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 * ---------------------------------------------------------------------------*/
12 #ifndef RTS_MESSAGES_H
13 #define RTS_MESSAGES_H
17 /* -----------------------------------------------------------------------------
19 * -------------------------------------------------------------------------- */
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.
26 * barf() invokes (*fatalInternalErrorFn)(). This function is not
29 void barf(const char *s, ...)
30 GNUC3_ATTRIBUTE(__noreturn__);
32 void vbarf(const char *s, va_list ap)
33 GNUC3_ATTRIBUTE(__noreturn__);
36 // extern void _assertFail(const char *filename, unsigned int linenum)
37 // GNUC3_ATTRIBUTE(__noreturn__);
40 * An error condition which is caused by and/or can be corrected by
43 * errorBelch() invokes (*errorMsgFn)().
45 void errorBelch(const char *s, ...)
46 GNUC3_ATTRIBUTE(format (printf, 1, 2));
48 void verrorBelch(const char *s, va_list ap);
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.
57 * sysErrorBelch() invokes (*sysErrorMsgFn)().
59 void sysErrorBelch(const char *s, ...)
60 GNUC3_ATTRIBUTE(format (printf, 1, 2));
62 void vsysErrorBelch(const char *s, va_list ap);
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).
69 * debugBelch() invokes (*debugMsgFn)().
71 void debugBelch(const char *s, ...)
72 GNUC3_ATTRIBUTE(format (printf, 1, 2));
74 void vdebugBelch(const char *s, va_list ap);
77 /* Hooks for redirecting message generation: */
79 typedef void RtsMsgFunction(const char *, va_list);
81 extern RtsMsgFunction *fatalInternalErrorFn;
82 extern RtsMsgFunction *debugMsgFn;
83 extern RtsMsgFunction *errorMsgFn;
85 /* Default stdio implementation of the message hooks: */
87 extern RtsMsgFunction rtsFatalInternalErrorFn;
88 extern RtsMsgFunction rtsDebugMsgFn;
89 extern RtsMsgFunction rtsErrorMsgFn;
90 extern RtsMsgFunction rtsSysErrorMsgFn;
92 #endif /* RTS_MESSAGES_H */