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