[project @ 2000-03-14 09:55:05 by simonmar]
[ghc-hetmet.git] / ghc / rts / RtsAPI.c
index 0009fb6..4d5b403 100644 (file)
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------------
- * $Id: RtsAPI.c,v 1.11 2000/03/13 10:53:56 simonmar Exp $
+ * $Id: RtsAPI.c,v 1.12 2000/03/14 09:55:05 simonmar Exp $
  *
- * (c) The GHC Team, 1998-1999
+ * (c) The GHC Team, 1998-2000
  *
  * API for invoking Haskell functions via the RTS
  *
@@ -22,7 +22,7 @@ HaskellObj
 rts_mkChar (char c)
 {
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
-  p->header.info = (const StgInfoTable*)&Czh_con_info;
+  p->header.info = Czh_con_info;
   p->payload[0]  = (StgClosure *)((StgInt)c);
   return p;
 }
@@ -31,7 +31,7 @@ HaskellObj
 rts_mkInt (int i)
 {
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
-  p->header.info = (const StgInfoTable*)&Izh_con_info;
+  p->header.info = Izh_con_info;
   p->payload[0]  = (StgClosure *)(StgInt)i;
   return p;
 }
@@ -44,7 +44,7 @@ rts_mkInt8 (int i)
      instead of the one for Int8, but the types have identical
      representation.
   */
-  p->header.info = (const StgInfoTable*)&Izh_con_info;
+  p->header.info = Izh_con_info;
   /* Make sure we mask out the bits above the lowest 8 */
   p->payload[0]  = (StgClosure *)(StgInt)((unsigned)i & 0xff);
   return p;
@@ -58,7 +58,7 @@ rts_mkInt16 (int i)
      instead of the one for Int8, but the types have identical
      representation.
   */
-  p->header.info = (const StgInfoTable*)&Izh_con_info;
+  p->header.info = Izh_con_info;
   /* Make sure we mask out the relevant bits */
   p->payload[0]  = (StgClosure *)(StgInt)((unsigned)i & 0xffff);
   return p;
@@ -69,7 +69,7 @@ rts_mkInt32 (int i)
 {
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
   /* see mk_Int8 comment */
-  p->header.info = (const StgInfoTable*)&Izh_con_info;
+  p->header.info = Izh_con_info;
   p->payload[0]  = (StgClosure *)(StgInt)i;
   return p;
 }
@@ -80,7 +80,7 @@ rts_mkInt64 (long long int i)
   long long *tmp;
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,2));
   /* see mk_Int8 comment */
-  p->header.info = (const StgInfoTable*)&I64zh_con_info;
+  p->header.info = I64zh_con_info;
   tmp  = (long long*)&(p->payload[0]);
   *tmp = (StgInt64)i;
   return p;
@@ -90,7 +90,7 @@ HaskellObj
 rts_mkWord (unsigned int i)
 {
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
-  p->header.info = (const StgInfoTable*)&Wzh_con_info;
+  p->header.info = Wzh_con_info;
   p->payload[0]  = (StgClosure *)(StgWord)i;
   return p;
 }
@@ -100,7 +100,7 @@ rts_mkWord8 (unsigned int w)
 {
   /* see rts_mkInt* comments */
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
-  p->header.info = (const StgInfoTable*)&Wzh_con_info;
+  p->header.info = Wzh_con_info;
   p->payload[0]  = (StgClosure *)(StgWord)(w & 0xff);
   return p;
 }
@@ -110,7 +110,7 @@ rts_mkWord16 (unsigned int w)
 {
   /* see rts_mkInt* comments */
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
-  p->header.info = (const StgInfoTable*)&Wzh_con_info;
+  p->header.info = Wzh_con_info;
   p->payload[0]  = (StgClosure *)(StgWord)(w & 0xffff);
   return p;
 }
@@ -120,7 +120,7 @@ rts_mkWord32 (unsigned int w)
 {
   /* see rts_mkInt* comments */
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
-  p->header.info = (const StgInfoTable*)&Wzh_con_info;
+  p->header.info = Wzh_con_info;
   p->payload[0]  = (StgClosure *)(StgWord)w;
   return p;
 }
@@ -132,7 +132,7 @@ rts_mkWord64 (unsigned long long w)
 
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,2));
   /* see mk_Int8 comment */
-  p->header.info = (const StgInfoTable*)&W64zh_con_info;
+  p->header.info = W64zh_con_info;
   tmp  = (unsigned long long*)&(p->payload[0]);
   *tmp = (StgWord64)w;
   return p;
@@ -142,7 +142,7 @@ HaskellObj
 rts_mkFloat (float f)
 {
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,1));
-  p->header.info = (const StgInfoTable*)&Fzh_con_info;
+  p->header.info = Fzh_con_info;
   ASSIGN_FLT((P_)p->payload, (StgFloat)f);
   return p;
 }
@@ -151,7 +151,7 @@ HaskellObj
 rts_mkDouble (double d)
 {
   StgClosure *p = (StgClosure *)allocate(CONSTR_sizeW(0,sizeofW(StgDouble)));
-  p->header.info = (const StgInfoTable*)&Dzh_con_info;
+  p->header.info = Dzh_con_info;
   ASSIGN_DBL((P_)p->payload, (StgDouble)d);
   return p;
 }
@@ -160,7 +160,7 @@ HaskellObj
 rts_mkStablePtr (StgStablePtr s)
 {
   StgClosure *p = (StgClosure *)allocate(sizeofW(StgHeader)+1);
-  p->header.info = (const StgInfoTable*)&StablePtr_con_info;
+  p->header.info = StablePtr_con_info;
   p->payload[0]  = (StgClosure *)s;
   return p;
 }
@@ -169,7 +169,7 @@ HaskellObj
 rts_mkAddr (void *a)
 {
   StgClosure *p = (StgClosure *)allocate(sizeofW(StgHeader)+1);
-  p->header.info = (const StgInfoTable*)&Azh_con_info;
+  p->header.info = Azh_con_info;
   p->payload[0]  = (StgClosure *)a;
   return p;
 }
@@ -179,16 +179,16 @@ HaskellObj
 rts_mkBool (int b)
 {
   if (b) {
-    return (StgClosure *)&True_closure;
+    return (StgClosure *)True_closure;
   } else {
-    return (StgClosure *)&False_closure;
+    return (StgClosure *)False_closure;
   }
 }
 
 HaskellObj
 rts_mkString (char *s)
 {
-  return rts_apply((StgClosure *)&unpackCString_closure, rts_mkAddr(s));
+  return rts_apply((StgClosure *)unpackCString_closure, rts_mkAddr(s));
 }
 #endif /* COMPILER */
 
@@ -210,8 +210,8 @@ rts_apply (HaskellObj f, HaskellObj arg)
 char
 rts_getChar (HaskellObj p)
 {
-  if ( p->header.info == (const StgInfoTable*)&Czh_con_info || 
-       p->header.info == (const StgInfoTable*)&Czh_static_info) {
+  if ( p->header.info == Czh_con_info || 
+       p->header.info == Czh_static_info) {
     return (char)(StgWord)(p->payload[0]);
   } else {
     barf("getChar: not a Char");
@@ -222,8 +222,8 @@ int
 rts_getInt (HaskellObj p)
 {
   if ( 1 ||
-       p->header.info == (const StgInfoTable*)&Izh_con_info || 
-       p->header.info == (const StgInfoTable*)&Izh_static_info ) {
+       p->header.info == Izh_con_info || 
+       p->header.info == Izh_static_info ) {
     return (int)(p->payload[0]);
   } else {
     barf("getInt: not an Int");
@@ -234,8 +234,8 @@ int
 rts_getInt32 (HaskellObj p)
 {
   if ( 1 ||
-       p->header.info == (const StgInfoTable*)&Izh_con_info || 
-       p->header.info == (const StgInfoTable*)&Izh_static_info ) {
+       p->header.info == Izh_con_info || 
+       p->header.info == Izh_static_info ) {
     return (int)(p->payload[0]);
   } else {
     barf("getInt: not an Int");
@@ -246,8 +246,8 @@ unsigned int
 rts_getWord (HaskellObj p)
 {
   if ( 1 || /* see above comment */
-       p->header.info == (const StgInfoTable*)&Wzh_con_info ||
-       p->header.info == (const StgInfoTable*)&Wzh_static_info ) {
+       p->header.info == Wzh_con_info ||
+       p->header.info == Wzh_static_info ) {
     return (unsigned int)(p->payload[0]);
   } else {
     barf("getWord: not a Word");
@@ -258,8 +258,8 @@ unsigned int
 rts_getWord32 (HaskellObj p)
 {
   if ( 1 || /* see above comment */
-       p->header.info == (const StgInfoTable*)&Wzh_con_info ||
-       p->header.info == (const StgInfoTable*)&Wzh_static_info ) {
+       p->header.info == Wzh_con_info ||
+       p->header.info == Wzh_static_info ) {
     return (unsigned int)(p->payload[0]);
   } else {
     barf("getWord: not a Word");
@@ -269,8 +269,8 @@ rts_getWord32 (HaskellObj p)
 float
 rts_getFloat (HaskellObj p)
 {
-  if ( p->header.info == (const StgInfoTable*)&Fzh_con_info || 
-       p->header.info == (const StgInfoTable*)&Fzh_static_info ) {
+  if ( p->header.info == Fzh_con_info || 
+       p->header.info == Fzh_static_info ) {
     return (float)(PK_FLT((P_)p->payload));
   } else {
     barf("getFloat: not a Float");
@@ -280,8 +280,8 @@ rts_getFloat (HaskellObj p)
 double
 rts_getDouble (HaskellObj p)
 {
-  if ( p->header.info == (const StgInfoTable*)&Dzh_con_info || 
-       p->header.info == (const StgInfoTable*)&Dzh_static_info ) {
+  if ( p->header.info == Dzh_con_info || 
+       p->header.info == Dzh_static_info ) {
     return (double)(PK_DBL((P_)p->payload));
   } else {
     barf("getDouble: not a Double");
@@ -291,8 +291,8 @@ rts_getDouble (HaskellObj p)
 StgStablePtr
 rts_getStablePtr (HaskellObj p)
 {
-  if ( p->header.info == (const StgInfoTable*)&StablePtr_con_info || 
-       p->header.info == (const StgInfoTable*)&StablePtr_static_info ) {
+  if ( p->header.info == StablePtr_con_info || 
+       p->header.info == StablePtr_static_info ) {
     return (StgStablePtr)(p->payload[0]);
   } else {
     barf("getStablePtr: not a StablePtr");
@@ -302,8 +302,8 @@ rts_getStablePtr (HaskellObj p)
 void *
 rts_getAddr (HaskellObj p)
 {
-  if ( p->header.info == (const StgInfoTable*)&Azh_con_info || 
-       p->header.info == (const StgInfoTable*)&Azh_static_info ) {
+  if ( p->header.info == Azh_con_info || 
+       p->header.info == Azh_static_info ) {
   
     return (void *)(p->payload[0]);
   } else {
@@ -315,9 +315,9 @@ rts_getAddr (HaskellObj p)
 int
 rts_getBool (HaskellObj p)
 {
-  if (p == &True_closure) {
+  if (p == True_closure) {
     return 1;
-  } else if (p == &False_closure) {
+  } else if (p == False_closure) {
     return 0;
   } else {
     barf("getBool: not a Bool");