[project @ 1999-04-27 10:59:29 by sewardj]
[ghc-hetmet.git] / ghc / includes / ClosureMacros.h
index f2352d9..4f170ca 100644 (file)
@@ -1,5 +1,5 @@
 /* ----------------------------------------------------------------------------
- * $Id: ClosureMacros.h,v 1.8 1999/03/11 11:21:45 simonm Exp $
+ * $Id: ClosureMacros.h,v 1.12 1999/04/27 10:59:30 sewardj Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -73,7 +73,7 @@ static __inline__ StgFunPtr get_entry(const StgInfoTable *itbl) {
 #define INIT_ENTRY(e)    code : {}
 #define GET_ENTRY(c)     stgCast(StgFunPtr,((c)->header.info))
 #define ENTRY_CODE(info) (info)
-#define INFO_PTR_TO_STRUCT(info) (stgCast(StgInfoTable*,info) - 1)
+#define INFO_PTR_TO_STRUCT(info) ((StgInfoTable *)(info) - 1)
 #define get_itbl(c)      (stgCast(StgInfoTable*,(c)->header.info) -1)
 static __inline__ StgFunPtr get_entry(const StgInfoTable *itbl) {
     return stgCast(StgFunPtr,itbl+1);
@@ -99,8 +99,8 @@ static __inline__ StgFunPtr get_entry(const StgInfoTable *itbl) {
  */
 extern StgFun start;
 
-extern StgWord TEXT_SECTION_END_MARKER_DECL[];
-extern StgWord DATA_SECTION_END_MARKER_DECL[];
+extern void* TEXT_SECTION_END_MARKER_DECL;
+extern void* DATA_SECTION_END_MARKER_DECL;
 
 #define IS_CODE_PTR(p) ((P_)(p) < (P_)&TEXT_SECTION_END_MARKER)
 #define IS_DATA_PTR(p) ((P_)(p) >= (P_)&TEXT_SECTION_END_MARKER && (P_)(p) < (P_)&DATA_SECTION_END_MARKER)
@@ -318,6 +318,14 @@ SET_STATIC_HDR(PrelBase_CZh_closure,PrelBase_CZh_info,costCentreStack,const);
 #define STATIC_LINK(info,p) \
    (*stgCast(StgClosure**,&((p)->payload[info->layout.payload.ptrs + \
                                        info->layout.payload.nptrs])))
+/* These macros are optimised versions of the above for certain
+ * closure types.  They *must* be equivalent to the generic
+ * STATIC_LINK.
+ */
+#define FUN_STATIC_LINK(p)   ((p)->payload[0])
+#define THUNK_STATIC_LINK(p) ((p)->payload[2])
+#define IND_STATIC_LINK(p)   ((p)->payload[1])
+
 #define STATIC_LINK2(info,p) \
    (*stgCast(StgClosure**,&((p)->payload[info->layout.payload.ptrs + \
                                        info->layout.payload.nptrs + 1])))
@@ -359,5 +367,7 @@ SET_STATIC_HDR(PrelBase_CZh_closure,PrelBase_CZh_info,costCentreStack,const);
 #define bcoConstFloat( bco, i )  (PK_FLT(stgCast(StgWord*,(bco)->payload+(bco)->n_ptrs+i)))
 #define bcoConstDouble( bco, i ) (PK_DBL(stgCast(StgWord*,(bco)->payload+(bco)->n_ptrs+i)))
 #define bcoInstr( bco, i )       (stgCast(StgWord8*,      ((bco)->payload+(bco)->n_ptrs+(bco)->n_words))[i])
+static __inline__ StgInt bcoInstr16 ( StgBCO* bco, unsigned int i )
+{ StgInt x = (bcoInstr(bco,i) << 8) + bcoInstr(bco,i+1); return x; }
 
 #endif /* CLOSUREMACROS_H */