[project @ 1997-08-25 21:03:29 by sof]
[ghc-hetmet.git] / ghc / includes / SMClosures.lh
index 326eaf3..fae88f1 100644 (file)
@@ -506,71 +506,90 @@ they will hear about it soon enough (WDP 95/05).
 
 %************************************************************************
 %*                                                                     *
-\subsubsection[MallocPtr-closures]{@MallocPtr@ closure macros}
+\subsubsection[ForeignObj-closures]{@ForeignObj@ closure macros}
 %*                                                                     *
 %************************************************************************
 
-Here's what a MallocPtr looks like:
+Here's what a ForeignObj looks like:
 
 \begin{verbatim}
             <Var  Hdr> 
-+----------+----------+------+------+
-| Info Ptr | Forward  | Data | List |
-+----------+----------+------+------+
++----------+----------+------+-------------+------+
+| Info Ptr | Forward  | Data | FreeRoutine | List |
++----------+----------+------+-------------+------+
 \end{verbatim}
 
-The list is a pointer to the next MallocPtr in the list of all
-MallocPtrs.  Note that it is essential that the garbage collector {\em
+@List@ is a pointer to the next ForeignObj in the list of all
+ForeignObjs.  Note that it is essential that the garbage collector {\em
 not\/} follow this link but that the link must get updated with the
 new address.
 
 The optional @Forward@ field is used by copying collectors to insert
 the forwarding pointer into.  (If we overwrite the @Data@ part, we
-don't know which MallocPtr has just died; if we overwrite the @List@ part,
-we can't traverse the list of all MallocPtrs.)
+don't know which ForeignObj has just died; if we overwrite the @List@ part,
+we can't traverse the list of all ForeignObjs.)
+
+The @FreeRoutine@ is a reference to the finalisation routine to call
+when the @ForeignObj@ becomes garbage -- SOF 4/96
+
+[8/97 -- from the p.o.v. of the NCG, it is very convenient if
+the offset to the data field is constant and not dependent on
+what scheme of GC being used by the RTS. So much so, that I'm
+uniformly adding a VHS of 1. For schemes using a copying
+collector, that's the forward field. For the one-space collector,
+it's an unused word. 
+
+If the change is reverted back to what it was (conditional on
+the setting of _INFO_COPYING), then MachMisc.foHS
+needs to be changed accordingly.               -- SOF]
 
 \begin{code}
 #if !defined(PAR)
 
+/* See comment above */
+#  define ForeignObj_VHS                       1
+/*
 # if defined(_INFO_COPYING)
-#  define MallocPtr_VHS                                1
+#  define ForeignObj_VHS                       1
 # else
-#  define MallocPtr_VHS                                0
+#  define ForeignObj_VHS                       0
 # endif
+*/
 
-# define MallocPtr_HS                  (FIXED_HS + MallocPtr_VHS)
-# define MallocPtr_SIZE                        (MallocPtr_VHS + 2)
+# define ForeignObj_HS                 (FIXED_HS + ForeignObj_VHS)
+# define ForeignObj_SIZE               (ForeignObj_VHS + 3)
 
-# define MallocPtr_CLOSURE_NoPTRS(closure)  0
-# define MallocPtr_CLOSURE_DATA(closure)    (((StgMallocPtr *)(closure))[MallocPtr_HS + 0])
-# define MallocPtr_CLOSURE_LINK(closure)    (((StgPtrPtr) (closure))[MallocPtr_HS + 1])
+# define ForeignObj_CLOSURE_NoPTRS(closure)     0
+# define ForeignObj_CLOSURE_DATA(closure)       (((StgForeignObj *)(closure))[ForeignObj_HS + 0])
+# define ForeignObj_CLOSURE_FINALISER(closure)  (((StgForeignObj *)(closure))[ForeignObj_HS + 1])
+# define ForeignObj_CLOSURE_LINK(closure)       (((StgPtrPtr) (closure))[ForeignObj_HS + 2])
 
-# define SET_MallocPtr_HDR(closure,infolbl,cc,size,ptrs) \
+# define SET_ForeignObj_HDR(closure,infolbl,cc,size,ptrs) \
                                        SET_FIXED_HDR(closure,infolbl,cc)
 \end{code}
 
-And to check that a Malloc ptr closure is valid
+And to check that a Foreign ptr closure is valid
 
 \begin{code}
-EXTDATA_RO(MallocPtr_info);
+EXTDATA_RO(ForeignObj_info);
 
 # if defined(DEBUG)
 
-#  define CHECK_MallocPtr_CLOSURE( closure ) \
+#  define CHECK_ForeignObj_CLOSURE( closure ) \
 do {                                       \
-  CHECK_MallocPtr_InfoTable( closure );    \
+  CHECK_ForeignObj_InfoTable( closure );    \
 } while (0)
 
-#  define CHECK_MallocPtr_InfoTable( closure ) \
-  ASSERT( (*((PP_)(closure))) == MallocPtr_info )
+#  define CHECK_ForeignObj_InfoTable( closure ) \
+  ASSERT( (*((PP_)(closure))) == ForeignObj_info )
 
-extern void Validate_MallocPtrList( P_ MPlist );
-#  define VALIDATE_MallocPtrList( mplist ) Validate_MallocPtrList( mplist )
+extern void Validate_ForeignObjList( P_ MPlist );
+#  define VALIDATE_ForeignObjList( mplist ) Validate_ForeignObjList( mplist )
 
 # else /* !DEBUG */
 
-#  define CHECK_MallocPtr_CLOSURE( closure ) /* nothing */
-#  define VALIDATE_MallocPtrList( mplist ) /* nothing */
+#  define CHECK_ForeignObj_CLOSURE( closure ) /* nothing */
+#  define VALIDATE_ForeignObjList( mplist ) /* nothing */
 
 # endif /* !DEBUG */
 #endif /* !PAR */
@@ -696,7 +715,7 @@ do {                                 \
 EXTDATA_RO(StablePointerTable_info);
 EXTDATA_RO(EmptyStablePointerTable_info);
 EXTDATA(EmptySPTable_closure);
-extern int ValidateSPTable PROTO(( P_ SPTable ));
+int ValidateSPTable PROTO(( P_ SPTable ));
 
 #  define CHECK_SPT_InfoTable( closure ) \
   ASSERT( (*((PP_) (closure)) == EmptyStablePointerTable_info && (closure == EmptySPTable_closure) ) || \
@@ -812,8 +831,8 @@ variable header):
 #define DATA_CLOSURE_NoPTRS(closure)    ((I_)0)
 #define DATA_CLOSURE_NoNONPTRS(closure) (DATA_CLOSURE_SIZE(closure) - DATA_VHS)
 
-#define SET_DATA_HDR(closure,infolbl,cc,size,ptrs/*==0*/)      \
-       { SET_FIXED_HDR(closure,infolbl,cc);                    \
+#define SET_DATA_HDR(closure,infolbl,cc,size,ptrs)     \
+       { SET_FIXED_HDR(closure,infolbl,cc);            \
          DATA_CLOSURE_SIZE(closure) = (W_)(size); }
 \end{code}
 
@@ -1063,7 +1082,11 @@ closures indexed by literal characters.  As with @CONST@ closures,
 #define CHARLIKE_CLOSURE_NoNONPTRS(closure)    (1L)
 
 /* Array of static charlike closures */
+#ifndef aix_TARGET_OS /* AIX gives link errors with consts in this file (RO assembler section) */
 extern const W_ CHARLIKE_closures[];
+#else
+extern W_ CHARLIKE_closures[];
+#endif
 
 /* Macro to retrieve static charlike closure */
 #define CHARLIKE_CLOSURE(the_char) \
@@ -1098,7 +1121,7 @@ the same structure as a @SPEC_1_0@ closure.
 #define INTLIKE_CLOSURE_NoNONPTRS(closure)     (1L)
 
 /* Array of static intlike closures */
-extern P_ INTLIKE_closures;
+extern const P_ INTLIKE_closures;
 
 /* Range of static intlike closures MAX_INTLIKE, MIN_INTLIKE is in GhcConstants.lh */