[ci skip] includes: detabify/dewhitespace rts/Hpc.h
[ghc.git] / includes / rts / Messages.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2009
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 * Do not #include this file directly: #include "Rts.h" instead.
11 *
12 * To understand the structure of the RTS headers, see the wiki:
13 * http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
14 *
15 * ---------------------------------------------------------------------------*/
16
17 #ifndef RTS_MESSAGES_H
18 #define RTS_MESSAGES_H
19
20 #include <stdarg.h>
21
22 #if defined(mingw32_HOST_OS)
23 /* On Win64, if we say "printf" then gcc thinks we are going to use
24 MS format specifiers like %I64d rather than %llu */
25 #define PRINTF gnu_printf
26 #else
27 /* However, on OS X, "gnu_printf" isn't recognised */
28 #define PRINTF printf
29 #endif
30
31 /* -----------------------------------------------------------------------------
32 * Message generation
33 * -------------------------------------------------------------------------- */
34
35 /*
36 * A fatal internal error: this is for errors that probably indicate
37 * bugs in the RTS or compiler. We normally output bug reporting
38 * instructions along with the error message.
39 *
40 * barf() invokes (*fatalInternalErrorFn)(). This function is not
41 * expected to return.
42 */
43 void barf(const char *s, ...)
44 GNUC3_ATTRIBUTE(__noreturn__);
45
46 void vbarf(const char *s, va_list ap)
47 GNUC3_ATTRIBUTE(__noreturn__);
48
49 // declared in Rts.h:
50 // extern void _assertFail(const char *filename, unsigned int linenum)
51 // GNUC3_ATTRIBUTE(__noreturn__);
52
53 /*
54 * An error condition which is caused by and/or can be corrected by
55 * the user.
56 *
57 * errorBelch() invokes (*errorMsgFn)().
58 */
59 void errorBelch(const char *s, ...)
60 GNUC3_ATTRIBUTE(format (PRINTF, 1, 2));
61
62 void verrorBelch(const char *s, va_list ap);
63
64 /*
65 * An error condition which is caused by and/or can be corrected by
66 * the user, and which has an associated error condition reported
67 * by the system (in errno on Unix, and GetLastError() on Windows).
68 * The system error message is appended to the message generated
69 * from the supplied format string.
70 *
71 * sysErrorBelch() invokes (*sysErrorMsgFn)().
72 */
73 void sysErrorBelch(const char *s, ...)
74 GNUC3_ATTRIBUTE(format (PRINTF, 1, 2));
75
76 void vsysErrorBelch(const char *s, va_list ap);
77
78 /*
79 * A debugging message. Debugging messages are generated either as a
80 * virtue of having DEBUG turned on, or by being explicitly selected
81 * via RTS options (eg. +RTS -Ds).
82 *
83 * debugBelch() invokes (*debugMsgFn)().
84 */
85 void debugBelch(const char *s, ...)
86 GNUC3_ATTRIBUTE(format (PRINTF, 1, 2));
87
88 void vdebugBelch(const char *s, va_list ap);
89
90
91 /* Hooks for redirecting message generation: */
92
93 typedef void RtsMsgFunction(const char *, va_list);
94
95 extern RtsMsgFunction *fatalInternalErrorFn;
96 extern RtsMsgFunction *debugMsgFn;
97 extern RtsMsgFunction *errorMsgFn;
98
99 /* Default stdio implementation of the message hooks: */
100
101 extern RtsMsgFunction rtsFatalInternalErrorFn;
102 extern RtsMsgFunction rtsDebugMsgFn;
103 extern RtsMsgFunction rtsErrorMsgFn;
104 extern RtsMsgFunction rtsSysErrorMsgFn;
105
106 #endif /* RTS_MESSAGES_H */