From f44abb206443fac9df36884fc1bb0cf73c30bea2 Mon Sep 17 00:00:00 2001 From: sof Date: Fri, 14 Aug 1998 10:50:32 +0000 Subject: [PATCH] [project @ 1998-08-14 10:50:30 by sof] Hooks now take a file descriptor, not a FILE --- ghc/runtime/hooks/ErrorHdr.lc | 7 +++---- ghc/runtime/hooks/IOErrorHdr.lc | 7 +++---- ghc/runtime/hooks/PatErrorHdr.lc | 7 +++---- ghc/runtime/hooks/TraceHooks.lc | 15 +++++++++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/ghc/runtime/hooks/ErrorHdr.lc b/ghc/runtime/hooks/ErrorHdr.lc index 3c04fec..9e32f4b 100644 --- a/ghc/runtime/hooks/ErrorHdr.lc +++ b/ghc/runtime/hooks/ErrorHdr.lc @@ -2,10 +2,9 @@ #include "rtsdefs.h" void -ErrorHdrHook (FILE *where) +ErrorHdrHook (StgInt fd) { - fflush( stdout ); /* Flush out any pending output */ - - fprintf(where, "\nFail: "); + const char msg[]="\nFail: "; + write(fd,msg,sizeof(msg)-1); } \end{code} diff --git a/ghc/runtime/hooks/IOErrorHdr.lc b/ghc/runtime/hooks/IOErrorHdr.lc index 73676f5..1c8e545 100644 --- a/ghc/runtime/hooks/IOErrorHdr.lc +++ b/ghc/runtime/hooks/IOErrorHdr.lc @@ -2,10 +2,9 @@ #include "rtsdefs.h" void -IOErrorHdrHook (FILE *where) +IOErrorHdrHook (StgInt fd) { - fflush( stdout ); /* Flush out any pending output */ - - fprintf(where, "\nI/O error: "); + const char msg[]="\nI/O error: "; + write(fd, msg, sizeof(msg)-1); } \end{code} diff --git a/ghc/runtime/hooks/PatErrorHdr.lc b/ghc/runtime/hooks/PatErrorHdr.lc index 2382049..11c4632 100644 --- a/ghc/runtime/hooks/PatErrorHdr.lc +++ b/ghc/runtime/hooks/PatErrorHdr.lc @@ -2,10 +2,9 @@ #include "rtsdefs.h" void -PatErrorHdrHook (FILE *where) +PatErrorHdrHook (StgInt fd) { - fflush( stdout ); /* Flush out any pending output */ - - fprintf(where, "\nFail: "); + const char msg[]="\nFail: "; + write(fd,msg,sizeof(msg)-1); } \end{code} diff --git a/ghc/runtime/hooks/TraceHooks.lc b/ghc/runtime/hooks/TraceHooks.lc index 67b7ea3..fc0e60e 100644 --- a/ghc/runtime/hooks/TraceHooks.lc +++ b/ghc/runtime/hooks/TraceHooks.lc @@ -2,14 +2,21 @@ #include "rtsdefs.h" void -PreTraceHook (FILE *where) +PreTraceHook (StgInt fd) { - fprintf(where, "Trace On:\n"); +/* By default, a trace msg doesn't have a header (nor a footer) */ +#if 0 + const char msg[]="Trace On:\n"; + write(fd,msg,sizeof(msg)-1); +#endif } void -PostTraceHook (FILE *where) +PostTraceHook (StgInt fd) { - fprintf(where, "\nTrace Off.\n"); +#if 0 + const char msg[]="\nTrace Off.\n"; + write(fd,msg,sizeof(msg)-1); +#endif } \end{code} -- 1.7.10.4