1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2004
5 * General utility functions used in the RTS.
7 * ---------------------------------------------------------------------------*/
14 /* -----------------------------------------------------------------------------
16 * -------------------------------------------------------------------------- */
19 * A fatal internal error: this is for errors that probably indicate
20 * bugs in the RTS or compiler. We normally output bug reporting
21 * instructions along with the error message.
23 extern void barf(char *s, ...)
24 GNUC3_ATTRIBUTE(__noreturn__);
27 * An error condition which is caused by and/or can be corrected by
30 extern void errorBelch(char *s, ...)
31 GNUC3_ATTRIBUTE(format (printf, 1, 2));
34 * A debugging message. Debugging messages are generated either as a
35 * virtue of having DEBUG turned on, or by being explicitly selected
36 * via RTS options (eg. +RTS -Ds).
38 extern void debugBelch(char *s, ...)
39 GNUC3_ATTRIBUTE(format (printf, 1, 2));
41 /* Version of debugBelch() that takes parameters as a va_list */
42 extern void vdebugBelch(char *s, va_list ap);
44 /* Hooks for redirecting message generation: */
46 typedef void RtsMsgFunction(char *, va_list);
48 extern RtsMsgFunction *fatalInternalMsgFn;
49 extern RtsMsgFunction *debugMsgFn;
50 extern RtsMsgFunction *errorMsgFn;
52 /* Default stdio implementation of the message hooks: */
54 extern RtsMsgFunction stdioFatalInternalMsgFn;
55 extern RtsMsgFunction stdioDebugMsgFn;
56 extern RtsMsgFunction stdioErrorMsgFn;
58 /* -----------------------------------------------------------------------------
59 * (Checked) dynamic allocation
60 * -------------------------------------------------------------------------- */
62 extern void *stgMallocBytes(int n, char *msg) GNUC3_ATTRIBUTE(__malloc__);
63 extern void *stgReallocBytes(void *p, int n, char *msg);
64 extern void *stgCallocBytes(int n, int m, char *msg) GNUC3_ATTRIBUTE(__malloc__);
65 extern void stgFree(void* p);
68 /* -----------------------------------------------------------------------------
69 * Misc other utilities
70 * -------------------------------------------------------------------------- */
72 extern void _stgAssert (char *filename, unsigned int linenum);
74 extern void heapOverflow(void);
76 extern void setNonBlockingFd(int fd);
77 extern void resetNonBlockingFd(int fd);
79 extern nat stg_strlen(char *str);
82 char *ullong_format_string(ullong, char *, rtsBool);
89 extern void heapCheckFail( void );
92 extern void* __hscore_get_saved_termios(int fd);
93 extern void __hscore_set_saved_termios(int fd, void* ts);