1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2004
5 * General utility functions used in the RTS.
7 * ---------------------------------------------------------------------------*/
9 #include "PosixSource.h"
14 /* -----------------------------------------------------------------------------
15 General message generation functions
17 All messages should go through here. We can't guarantee that
18 stdout/stderr will be available - e.g. in a Windows program there
19 is no console for generating messages, so they have to either go to
20 to the debug console, or pop up message boxes.
21 -------------------------------------------------------------------------- */
23 // Default to the stdio implementation of these hooks.
24 RtsMsgFunction *fatalInternalErrorFn = stdioFatalInternalErrorFn;
25 RtsMsgFunction *debugMsgFn = stdioDebugMsgFn;
26 RtsMsgFunction *errorMsgFn = stdioErrorMsgFn;
33 (*fatalInternalErrorFn)(s,ap);
34 stg_exit(EXIT_INTERNAL_ERROR); // just in case fatalInternalErrorFn() returns
39 vbarf(char *s, va_list ap)
41 (*fatalInternalErrorFn)(s,ap);
42 stg_exit(EXIT_INTERNAL_ERROR); // just in case fatalInternalErrorFn() returns
46 errorBelch(char *s, ...)
55 verrorBelch(char *s, va_list ap)
61 debugBelch(char *s, ...)
70 vdebugBelch(char *s, va_list ap)
75 /* -----------------------------------------------------------------------------
76 stdio versions of the message functions
77 -------------------------------------------------------------------------- */
80 stdioFatalInternalErrorFn(char *s, va_list ap)
82 /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
83 if (prog_argv != NULL && prog_name != NULL) {
84 fprintf(stderr, "%s: internal error: ", prog_name);
86 fprintf(stderr, "internal error: ");
88 vfprintf(stderr, s, ap);
89 fprintf(stderr, "\n");
90 fprintf(stderr, " Please report this as a bug to glasgow-haskell-bugs@haskell.org,\n or http://www.sourceforge.net/projects/ghc/\n");
92 stg_exit(EXIT_INTERNAL_ERROR);
96 stdioErrorMsgFn(char *s, va_list ap)
98 /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
99 if (prog_argv != NULL && prog_name != NULL) {
100 fprintf(stderr, "%s: ", prog_name);
102 vfprintf(stderr, s, ap);
103 fprintf(stderr, "\n");
107 stdioDebugMsgFn(char *s, va_list ap)
109 /* don't fflush(stdout); WORKAROUND bug in Linux glibc */
110 vfprintf(stderr, s, ap);