[project @ 2002-07-17 09:21:48 by simonmar]
authorsimonmar <unknown>
Wed, 17 Jul 2002 09:21:51 +0000 (09:21 +0000)
committersimonmar <unknown>
Wed, 17 Jul 2002 09:21:51 +0000 (09:21 +0000)
Remove most #includes of system headers from Stg.h, and instead
#include any required headers directly in each RTS source file.

The idea is to (a) reduce namespace pollution from system headers that
we don't need, (c) be clearer about dependencies on system things in
the RTS, and (c) improve via-C compilation times (maybe).

In practice though, HsBase.h #includes everything anyway, so the
difference from the point of view of .hc source is minimal.  However,
this makes it easier to move to zero-includes if we wanted to (see
discussion on the FFI list; I'm still not sure that's possible but
at least this is a step in the right direction).

29 files changed:
ghc/includes/PrimOps.h
ghc/includes/RtsFlags.h
ghc/includes/Stg.h
ghc/includes/mkNativeHdr.c
ghc/rts/Arena.c
ghc/rts/BlockAlloc.c
ghc/rts/Disassembler.c
ghc/rts/GC.c
ghc/rts/Hash.c
ghc/rts/Itimer.c
ghc/rts/MBlock.c
ghc/rts/PrimOps.hc
ghc/rts/Printer.c
ghc/rts/RtsFlags.c
ghc/rts/RtsStartup.c
ghc/rts/RtsUtils.c
ghc/rts/Schedule.c
ghc/rts/Select.c
ghc/rts/Signals.c
ghc/rts/StgPrimFloat.c
ghc/rts/Storage.c
ghc/rts/ThreadLabels.c
ghc/rts/hooks/ErrorHdr.c
ghc/rts/hooks/MallocFail.c
ghc/rts/hooks/NoRunnableThreads.c
ghc/rts/hooks/OutOfHeap.c
ghc/rts/hooks/PatErrorHdr.c
ghc/rts/hooks/RtsOpts.c
ghc/rts/hooks/StackOverflow.c

index 2027cde..61dcf84 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PrimOps.h,v 1.95 2002/06/04 16:13:53 sof Exp $
+ * $Id: PrimOps.h,v 1.96 2002/07/17 09:21:48 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -326,11 +326,10 @@ EXTFUN_RTS(mkApUpd0zh_fast);
 #define STG_SIG_ERR  (-3)
 #define STG_SIG_HAN  (-4)
 
-extern StgInt stg_sig_install (StgInt, StgInt, StgStablePtr, sigset_t *);
-#define stg_sig_default(sig,mask) stg_sig_install(sig,STG_SIG_DFL,0,(sigset_t *)mask)
-#define stg_sig_ignore(sig,mask) stg_sig_install(sig,STG_SIG_IGN,0,(sigset_t *)mask)
-#define stg_sig_catch(sig,ptr,mask) stg_sig_install(sig,STG_SIG_HAN,ptr,(sigset_t *)mask)
-
+extern StgInt stg_sig_install (StgInt, StgInt, StgStablePtr, void *);
+#define stg_sig_default(sig,mask) stg_sig_install(sig,STG_SIG_DFL,0,(void *)mask)
+#define stg_sig_ignore(sig,mask) stg_sig_install(sig,STG_SIG_IGN,0,(void *)mask)
+#define stg_sig_catch(sig,ptr,mask) stg_sig_install(sig,STG_SIG_HAN,ptr,(void *)mask)
 
 /* ------------------------------------------------------------------------
    Parallel PrimOps
index 9f4bef3..209a0b3 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsFlags.h,v 1.41 2001/12/12 14:58:26 simonmar Exp $
+ * $Id: RtsFlags.h,v 1.42 2002/07/17 09:21:49 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -10,6 +10,8 @@
 #ifndef RTSFLAGS_H
 #define RTSFLAGS_H
 
+#include <stdio.h>
+
 /* For defaults, see the @initRtsFlagsDefaults@ routine. */
 
 struct GC_FLAGS {
index f176700..f863b55 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Stg.h,v 1.46 2002/06/03 13:08:41 matthewc Exp $
+ * $Id: Stg.h,v 1.47 2002/07/17 09:21:49 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -186,22 +186,6 @@ typedef StgWord64       LW_;
 /* RTS public interface */
 #include "RtsAPI.h"
 
-/* these are all ANSI C headers */
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef SMP
 #include <pthread.h>
 #endif
index ebc951f..c04d158 100644 (file)
@@ -1,5 +1,5 @@
 /* --------------------------------------------------------------------------
- * $Id: mkNativeHdr.c,v 1.8 2002/01/08 10:36:24 sewardj Exp $
+ * $Id: mkNativeHdr.c,v 1.9 2002/07/17 09:21:49 simonmar Exp $
  *
  * (c) The GHC Team, 1992-1998
  *
@@ -7,6 +7,8 @@
  *
  * ------------------------------------------------------------------------*/
 
+#include <stdio.h>
+
 #include "Stg.h"
 
 #define OFFSET(table, x) ((StgUnion *) &(x) - (StgUnion *) (&table))
index f719400..ba6774b 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
-   $Id: Arena.c,v 1.1 2001/10/18 14:41:01 simonmar Exp $ 
+   $Id: Arena.c,v 1.2 2002/07/17 09:21:49 simonmar Exp $ 
    (c) The University of Glasgow 2001
 
    Arena allocation.  Arenas provide fast memory allocation at the
@@ -24,6 +24,8 @@
 #include "BlockAlloc.h"
 #include "Arena.h"
 
+#include <stdlib.h>
+
 // Each arena struct is allocated using malloc().
 struct _Arena {
     bdescr *current;
index f33ab86..9d13719 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: BlockAlloc.c,v 1.13 2001/11/08 14:42:11 simonmar Exp $
+ * $Id: BlockAlloc.c,v 1.14 2002/07/17 09:21:49 simonmar Exp $
  *
  * (c) The GHC Team 1998-2000
  * 
@@ -23,6 +23,8 @@
 #include "BlockAlloc.h"
 #include "MBlock.h"
 
+#include <string.h>
+
 static void    initMBlock(void *mblock);
 static bdescr *allocMegaGroup(nat mblocks);
 static void    freeMegaGroup(bdescr *bd);
index 0063a65..8b526c0 100644 (file)
@@ -5,8 +5,8 @@
  * Copyright (c) 1994-1998.
  *
  * $RCSfile: Disassembler.c,v $
- * $Revision: 1.24 $
- * $Date: 2001/08/14 13:40:09 $
+ * $Revision: 1.25 $
+ * $Date: 2002/07/17 09:21:49 $
  * ---------------------------------------------------------------------------*/
 
 #ifdef DEBUG
@@ -24,6 +24,8 @@
 #include "Disassembler.h"
 #include "Interpreter.h"
 
+#include <stdio.h>
+
 /* --------------------------------------------------------------------------
  * Disassembler
  * ------------------------------------------------------------------------*/
index 80f7291..14dc91f 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: GC.c,v 1.136 2002/07/10 09:28:54 simonmar Exp $
+ * $Id: GC.c,v 1.137 2002/07/17 09:21:49 simonmar Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -45,6 +45,8 @@
 #include "RetainerProfile.h"
 #include "LdvProfile.h"
 
+#include <string.h>
+
 /* STATIC OBJECT LIST.
  *
  * During GC:
index 05f2b19..38cb65a 100644 (file)
@@ -1,5 +1,5 @@
 /*-----------------------------------------------------------------------------
- * $Id: Hash.c,v 1.8 2002/04/09 12:55:11 simonmar Exp $
+ * $Id: Hash.c,v 1.9 2002/07/17 09:21:49 simonmar Exp $
  *
  * (c) The AQUA Project, Glasgow University, 1995-1998
  * (c) The GHC Team, 1999
@@ -14,6 +14,9 @@
 #include "Hash.h"
 #include "RtsUtils.h"
 
+#include <stdlib.h>
+#include <string.h>
+
 #define HSEGSIZE    1024    /* Size of a single hash table segment */
                            /* Also the minimum size of a hash table */
 #define HDIRSIZE    1024    /* Size of the segment directory */
index 9df937b..e40c83d 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Itimer.c,v 1.29 2001/11/27 01:57:59 sof Exp $
+ * $Id: Itimer.c,v 1.30 2002/07/17 09:21:49 simonmar Exp $
  *
  * (c) The GHC Team, 1995-1999
  *
 # include <windows.h>
 #endif
  
+#ifdef HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+
 lnat total_ticks = 0;
 
 /* ticks left before next pre-emptive context switch */
index 7bb39d7..eaf6801 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: MBlock.c,v 1.28 2002/04/12 04:00:35 sof Exp $
+ * $Id: MBlock.c,v 1.29 2002/07/17 09:21:50 simonmar Exp $
  *
  * (c) The GHC Team 1998-1999
  *
@@ -40,6 +40,8 @@
 #include <windows.h>
 #endif
 
+#include <errno.h>
+
 lnat mblocks_allocated = 0;
 
 void *
index 44bedf6..0196e21 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PrimOps.hc,v 1.99 2002/06/26 08:18:41 stolz Exp $
+ * $Id: PrimOps.hc,v 1.100 2002/07/17 09:21:50 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
 #include "Itimer.h"
 #include "Prelude.h"
 
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#include <stdlib.h>
+
 /* ** temporary **
 
    classes CCallable and CReturnable don't really exist, but the
index abbc91b..9277c72 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Printer.c,v 1.51 2002/02/04 20:26:25 sof Exp $
+ * $Id: Printer.c,v 1.52 2002/07/17 09:21:50 simonmar Exp $
  *
  * (c) The GHC Team, 1994-2000.
  *
@@ -11,6 +11,8 @@
 #include "Rts.h"
 #include "Printer.h"
 
+#include <stdio.h>
+
 #ifdef DEBUG
 
 #include "RtsUtils.h"
@@ -20,7 +22,8 @@
 #include "Bytecodes.h"  /* for InstrPtr */
 #include "Disassembler.h"
 
-#include "Printer.h"
+#include <stdlib.h>
+#include <string.h>
 
 #if defined(GRAN) || defined(PAR)
 // HWL: explicit fixed header size to make debugging easier
index f9ddc83..0014664 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsFlags.c,v 1.56 2001/12/12 14:31:43 simonmar Exp $
+ * $Id: RtsFlags.c,v 1.57 2002/07/17 09:21:50 simonmar Exp $
  *
  * (c) The AQUA Project, Glasgow University, 1994-1997
  * (c) The GHC Team, 1998-1999
@@ -37,6 +37,9 @@
 #include <ctype.h>
 #endif
 
+#include <stdlib.h>
+#include <string.h>
+
 extern struct RTS_FLAGS RtsFlags;
 
 /*
index 7b308ea..c375426 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsStartup.c,v 1.64 2002/06/26 08:18:41 stolz Exp $
+ * $Id: RtsStartup.c,v 1.65 2002/07/17 09:21:50 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -50,6 +50,8 @@
 # include "LLC.h"
 #endif
 
+#include <stdlib.h>
+
 /*
  * Flag Structure
  */
index 3ff2f41..693531e 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsUtils.c,v 1.25 2002/05/18 05:28:14 ken Exp $
+ * $Id: RtsUtils.c,v 1.26 2002/07/17 09:21:50 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -31,6 +31,8 @@
 #include <sys/time.h>
 #endif
 
+#include <stdlib.h>
+#include <string.h>
 #include <stdarg.h>
 
 /* variable-argument error function. */
index 756d476..9b9f40c 100644 (file)
@@ -1,5 +1,5 @@
 /* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.147 2002/07/10 09:28:56 simonmar Exp $
+ * $Id: Schedule.c,v 1.148 2002/07/17 09:21:50 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
 #include <unistd.h>
 #endif
 
+#include <string.h>
+#include <stdlib.h>
 #include <stdarg.h>
 
 //@node Variables and Data structures, Prototypes, Includes, Main scheduling code
index 922b151..a2c990e 100644 (file)
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------------
- * $Id: Select.c,v 1.20 2002/07/09 20:44:24 sof Exp $
+ * $Id: Select.c,v 1.21 2002/07/17 09:21:51 simonmar Exp $
  *
- * (c) The GHC Team 1995-1999
+ * (c) The GHC Team 1995-2002
  *
  * Support for concurrent non-blocking I/O and thread waiting.
  *
@@ -29,6 +29,9 @@
 #  include <windows.h>
 # endif
 
+#include <errno.h>
+#include <string.h>
+
 /* last timestamp */
 nat timestamp = 0;
 
index b94ad6d..40535af 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Signals.c,v 1.25 2002/07/02 12:24:48 simonmar Exp $
+ * $Id: Signals.c,v 1.26 2002/07/17 09:21:51 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
 #include "StablePriv.h"
 
 #ifdef alpha_TARGET_ARCH
-#include <machine/fpu.h>
+# include <machine/fpu.h>
 #endif
 
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+# include <signal.h>
+#endif
+
+#include <stdlib.h>
+
 #ifndef mingw32_TARGET_OS
 
 #ifndef PAR
@@ -187,7 +197,7 @@ awaitUserSignals(void)
  * -------------------------------------------------------------------------- */
 
 StgInt 
-stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, sigset_t *mask)
+stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, void *mask)
 {
     sigset_t signals;
     struct sigaction action;
@@ -228,8 +238,8 @@ stg_sig_install(StgInt sig, StgInt spi, StgStablePtr handler, sigset_t *mask)
         barf("stg_sig_install: bad spi");
     }
 
-    if (mask != 0)
-        action.sa_mask = *mask;
+    if (mask != NULL)
+        action.sa_mask = *(sigset_t *)mask;
     else
        sigemptyset(&action.sa_mask);
 
index 1be9995..a0cc95d 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgPrimFloat.c,v 1.8 2001/08/14 13:40:09 sewardj Exp $
+ * $Id: StgPrimFloat.c,v 1.9 2002/07/17 09:21:51 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -10,6 +10,8 @@
 #include "PosixSource.h"
 #include "Rts.h"
 
+#include <math.h>
+
 /*
  * Encoding and decoding Doubles.  Code based on the HBC code
  * (lib/fltcode.c).
index 79c3ef7..f7a321d 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Storage.c,v 1.66 2002/05/14 08:17:38 matthewc Exp $
+ * $Id: Storage.c,v 1.67 2002/07/17 09:21:51 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -26,6 +26,9 @@
 
 #include "RetainerProfile.h"   // for counting memory blocks (memInventory)
 
+#include <stdlib.h>
+#include <string.h>
+
 #ifdef darwin_TARGET_OS
 #include <mach-o/getsect.h>
 unsigned long macho_etext = 0;
index fda40c3..79a0a77 100644 (file)
@@ -2,6 +2,8 @@
 #include "PosixSource.h"
 #include "ThreadLabels.h"
 
+#include <stdlib.h>
+
 HashTable * threadLabels = NULL;
 
 void
index 2797ca4..0f253d3 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: ErrorHdr.c,v 1.2 1998/12/02 13:29:11 simonm Exp $
+ * $Id: ErrorHdr.c,v 1.3 2002/07/17 09:21:51 simonmar Exp $
  *
  * User-overridable RTS hooks.
  *
@@ -7,6 +7,10 @@
 
 #include "Rts.h"
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 void
 ErrorHdrHook (long fd)
 {
index 01f534e..c4af10a 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: MallocFail.c,v 1.2 1998/12/02 13:29:12 simonm Exp $
+ * $Id: MallocFail.c,v 1.3 2002/07/17 09:21:51 simonmar Exp $
  *
  * User-overridable RTS hooks.
  *
@@ -7,6 +7,8 @@
 
 #include "Rts.h"
 
+#include <stdio.h>
+
 void
 MallocFailHook (lnat request_size /* in bytes */, char *msg)
 {
index 209e465..c5acd2e 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: NoRunnableThreads.c,v 1.2 1998/12/02 13:29:13 simonm Exp $
+ * $Id: NoRunnableThreads.c,v 1.3 2002/07/17 09:21:51 simonmar Exp $
  *
  * User-overridable RTS hooks.
  *
@@ -7,6 +7,8 @@
 
 #include "Rts.h"
 
+#include <stdio.h>
+
 /*
   Hook to invoke when there's nothing left on the runnable threads
   queue {\em and} we've got nothing to wait for. The value
index b09dbd1..ec02a7f 100644 (file)
@@ -1,11 +1,12 @@
 /* -----------------------------------------------------------------------------
- * $Id: OutOfHeap.c,v 1.3 1999/06/29 13:06:45 panne Exp $
+ * $Id: OutOfHeap.c,v 1.4 2002/07/17 09:21:51 simonmar Exp $
  *
  * User-overridable RTS hooks.
  *
  * ---------------------------------------------------------------------------*/
 
 #include "Rts.h"
+#include <stdio.h>
 
 void
 OutOfHeapHook (lnat request_size, lnat heap_size) /* both sizes in bytes */
index 633a982..eb39b95 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PatErrorHdr.c,v 1.2 1998/12/02 13:29:15 simonm Exp $
+ * $Id: PatErrorHdr.c,v 1.3 2002/07/17 09:21:51 simonmar Exp $
  *
  * User-overridable RTS hooks.
  *
@@ -7,6 +7,10 @@
 
 #include "Rts.h"
 
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 void
 PatErrorHdrHook (long fd)
 {
index dec0075..177086d 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: RtsOpts.c,v 1.1 2001/10/01 11:36:29 simonmar Exp $
+ * $Id: RtsOpts.c,v 1.2 2002/07/17 09:21:51 simonmar Exp $
  *
  * Default RTS options.
  *
@@ -7,6 +7,8 @@
 
 #include "Rts.h"
 
+#include <stdlib.h>
+
 // Default RTS options can be given by providing an alternate
 // definition for this variable, pointing to a string of RTS options.
 char *ghc_rts_opts = NULL;
index a467502..a14b069 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StackOverflow.c,v 1.2 1998/12/02 13:29:15 simonm Exp $
+ * $Id: StackOverflow.c,v 1.3 2002/07/17 09:21:51 simonmar Exp $
  *
  * User-overridable RTS hooks.
  *
@@ -7,6 +7,8 @@
 
 #include "Rts.h"
 
+#include <stdio.h>
+
 void
 StackOverflowHook (lnat stack_size)    /* in bytes */
 {