[project @ 2004-09-06 11:10:32 by simonmar]
[ghc-hetmet.git] / ghc / includes / RtsMessages.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 RTSMESSAGES_H
13 #define RTSMESSAGES_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 extern void barf(char *s, ...) 
30    GNUC3_ATTRIBUTE(__noreturn__);
31
32 extern void vbarf(char *s, va_list ap)
33    GNUC3_ATTRIBUTE(__noreturn__);
34
35 /*
36  * An error condition which is caused by and/or can be corrected by
37  * the user.
38  *
39  * errorBelch() invokes (*errorMsgFn)().
40  */
41 extern void errorBelch(char *s, ...)
42    GNUC3_ATTRIBUTE(format (printf, 1, 2));
43
44 extern void verrorBelch(char *s, va_list ap);
45
46 /*
47  * A debugging message.  Debugging messages are generated either as a
48  * virtue of having DEBUG turned on, or by being explicitly selected
49  * via RTS options (eg. +RTS -Ds).
50  *
51  * debugBelch() invokes (*debugMsgFn)().
52  */
53 extern void debugBelch(char *s, ...)
54    GNUC3_ATTRIBUTE(format (printf, 1, 2));
55
56 extern void vdebugBelch(char *s, va_list ap);
57
58
59 /* Hooks for redirecting message generation: */
60
61 typedef void RtsMsgFunction(char *, va_list);
62
63 extern RtsMsgFunction *fatalInternalErrorFn;
64 extern RtsMsgFunction *debugMsgFn;
65 extern RtsMsgFunction *errorMsgFn;
66
67 /* Default stdio implementation of the message hooks: */
68
69 extern RtsMsgFunction stdioFatalInternalErrorFn;
70 extern RtsMsgFunction stdioDebugMsgFn;
71 extern RtsMsgFunction stdioErrorMsgFn;
72
73 #endif // RTSMESSAGES_H