X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FRtsUtils.c;h=89a8af1e667842e284288a42c2b6a95b5f2e7332;hb=1d10874717ff05d2babc9cbf079d5895fcc0a922;hp=69a1450aea0d3ab1b30863beb22dc2815df69329;hpb=ba90d7e0d34e6fd8afb8271c56be9cca2bde0809;p=ghc-hetmet.git diff --git a/ghc/rts/RtsUtils.c b/ghc/rts/RtsUtils.c index 69a1450..89a8af1 100644 --- a/ghc/rts/RtsUtils.c +++ b/ghc/rts/RtsUtils.c @@ -1,7 +1,6 @@ /* ----------------------------------------------------------------------------- - * $Id: RtsUtils.c,v 1.28 2002/10/05 22:31:04 panne Exp $ * - * (c) The GHC Team, 1998-1999 + * (c) The GHC Team, 1998-2004 * * General utility functions used in the RTS. * @@ -11,11 +10,8 @@ /* #include "PosixSource.h" */ #include "Rts.h" -#include "RtsTypes.h" #include "RtsAPI.h" #include "RtsFlags.h" -#include "Hooks.h" -#include "Main.h" #include "RtsUtils.h" #include "Ticky.h" @@ -34,50 +30,11 @@ #include #include #include +#include -/* variable-argument error function. */ - -void barf(char *s, ...) -{ - va_list ap; - va_start(ap,s); - /* don't fflush(stdout); WORKAROUND bug in Linux glibc */ - if (prog_argv != NULL && prog_argv[0] != NULL) { - fprintf(stderr, "%s: fatal error: ", prog_argv[0]); - } else { - fprintf(stderr, "fatal error: "); - } - vfprintf(stderr, s, ap); - fprintf(stderr, "\n"); - fflush(stderr); - stg_exit(EXIT_INTERNAL_ERROR); - va_end(ap); -} - -void prog_belch(char *s, ...) -{ - va_list ap; - va_start(ap,s); - /* don't fflush(stdout); WORKAROUND bug in Linux glibc */ - if (prog_argv != NULL && prog_argv[0] != NULL) { - fprintf(stderr, "%s: ", prog_argv[0]); - } - vfprintf(stderr, s, ap); - fprintf(stderr, "\n"); - va_end(ap); -} - -void belch(char *s, ...) -{ - va_list ap; - va_start(ap,s); - /* don't fflush(stdout); WORKAROUND bug in Linux glibc */ - vfprintf(stderr, s, ap); - fprintf(stderr, "\n"); - va_end(ap); -} - -/* result-checking malloc wrappers. */ +/* ----------------------------------------------------------------------------- + Result-checking malloc wrappers. + -------------------------------------------------------------------------- */ void * stgMallocBytes (int n, char *msg) @@ -106,18 +63,6 @@ stgReallocBytes (void *p, int n, char *msg) } void * -stgMallocWords (int n, char *msg) -{ - return(stgMallocBytes(n * sizeof(W_), msg)); -} - -void * -stgReallocWords (void *p, int n, char *msg) -{ - return(stgReallocBytes(p, n * sizeof(W_), msg)); -} - -void * stgCallocBytes (int n, int m, char *msg) { int i; @@ -127,6 +72,15 @@ stgCallocBytes (int n, int m, char *msg) return p; } +/* To simplify changing the underlying allocator used + * by stgMallocBytes(), provide stgFree() as well. + */ +void +stgFree(void* p) +{ + free(p); +} + void _stgAssert (char *filename, unsigned int linenum) { @@ -249,14 +203,19 @@ setNonBlockingFd(int fd) /* clear the non-blocking flag on this file descriptor */ fd_flags = fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK); + if (!(fd_flags & O_NONBLOCK)) { + fcntl(fd, F_SETFL, fd_flags | O_NONBLOCK); + } } #else -/* Don't support non-blocking FDs (yet) on mingw */ +/* Stub defns -- async / non-blocking IO is not done + * via O_NONBLOCK and select() under Win32. + */ void resetNonBlockingFd(int fd STG_UNUSED) {} void setNonBlockingFd(int fd STG_UNUSED) {} #endif +#ifdef PAR static ullong startTime = 0; /* used in a parallel setup */ @@ -291,6 +250,7 @@ msTime(void) return t * LL(1000) - startTime; # endif } +#endif /* PAR */ /* ----------------------------------------------------------------------------- Print large numbers, with punctuation. @@ -318,3 +278,13 @@ ullong_format_string(ullong x, char *s, rtsBool with_commas) (lnat)((x)%(ullong)1000)); return s; } + + +// Can be used as a breakpoint to set on every heap check failure. +#ifdef DEBUG +void +heapCheckFail( void ) +{ +} +#endif +