~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to includes/rts/Messages.h

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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://hackage.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
/* -----------------------------------------------------------------------------
 
23
 * Message generation
 
24
 * -------------------------------------------------------------------------- */
 
25
 
 
26
/*
 
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.
 
30
 *
 
31
 * barf() invokes (*fatalInternalErrorFn)().  This function is not
 
32
 * expected to return.
 
33
 */
 
34
void barf(const char *s, ...)
 
35
   GNUC3_ATTRIBUTE(__noreturn__);
 
36
 
 
37
void vbarf(const char *s, va_list ap)
 
38
   GNUC3_ATTRIBUTE(__noreturn__);
 
39
 
 
40
// declared in Rts.h:
 
41
// extern void _assertFail(const char *filename, unsigned int linenum)
 
42
//    GNUC3_ATTRIBUTE(__noreturn__);
 
43
 
 
44
/*
 
45
 * An error condition which is caused by and/or can be corrected by
 
46
 * the user.
 
47
 *
 
48
 * errorBelch() invokes (*errorMsgFn)().
 
49
 */
 
50
void errorBelch(const char *s, ...)
 
51
   GNUC3_ATTRIBUTE(format (printf, 1, 2));
 
52
 
 
53
void verrorBelch(const char *s, va_list ap);
 
54
 
 
55
/*
 
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.
 
61
 *
 
62
 * sysErrorBelch() invokes (*sysErrorMsgFn)().
 
63
 */
 
64
void sysErrorBelch(const char *s, ...)
 
65
   GNUC3_ATTRIBUTE(format (printf, 1, 2));
 
66
 
 
67
void vsysErrorBelch(const char *s, va_list ap);
 
68
 
 
69
/*
 
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).
 
73
 *
 
74
 * debugBelch() invokes (*debugMsgFn)().
 
75
 */
 
76
void debugBelch(const char *s, ...)
 
77
   GNUC3_ATTRIBUTE(format (printf, 1, 2));
 
78
 
 
79
void vdebugBelch(const char *s, va_list ap);
 
80
 
 
81
 
 
82
/* Hooks for redirecting message generation: */
 
83
 
 
84
typedef void RtsMsgFunction(const char *, va_list);
 
85
 
 
86
extern RtsMsgFunction *fatalInternalErrorFn;
 
87
extern RtsMsgFunction *debugMsgFn;
 
88
extern RtsMsgFunction *errorMsgFn;
 
89
 
 
90
/* Default stdio implementation of the message hooks: */
 
91
 
 
92
extern RtsMsgFunction rtsFatalInternalErrorFn;
 
93
extern RtsMsgFunction rtsDebugMsgFn;
 
94
extern RtsMsgFunction rtsErrorMsgFn;
 
95
extern RtsMsgFunction rtsSysErrorMsgFn;
 
96
 
 
97
#endif /* RTS_MESSAGES_H */