Commit 65ace55b authored by simonmar's avatar simonmar

[project @ 2000-12-12 12:19:57 by simonmar]

- Add primops for {read,write,index}{Int,Word}{8,16,32,64}OffAddr.
    This enables us to remove all the _casm_s from Int/Word.

  - Replace new{Char,Int,etc.}Array# with newByteArray# (save a few primops,
    at the cost of having to know the size of these types in PrelArr).

  - Implement MArray/IArray support for sized types.  finally.

  - Move the guts of the sized types into ghc/lib/std, we'll need
    them for doing more FFIish things in the Prelude.
parent d6684fe7
......@@ -196,8 +196,8 @@ pREL_FLOAT_Name = mkModuleName "PrelFloat"
pREL_MAIN_Name = mkModuleName "PrelMain"
mAIN_Name = mkModuleName "Main"
iNT_Name = mkModuleName "Int"
wORD_Name = mkModuleName "Word"
pREL_INT_Name = mkModuleName "PrelInt"
pREL_WORD_Name = mkModuleName "PrelWord"
pREL_GHC = mkPrelModule pREL_GHC_Name
pREL_BASE = mkPrelModule pREL_BASE_Name
......@@ -420,16 +420,16 @@ bindIOName = varQual pREL_IO_BASE_Name SLIT("bindIO") bindIOIdKey
returnIOName = varQual pREL_IO_BASE_Name SLIT("returnIO") returnIOIdKey
-- Int, Word, and Addr things
int8TyConName = tcQual iNT_Name SLIT("Int8") int8TyConKey
int16TyConName = tcQual iNT_Name SLIT("Int16") int16TyConKey
int32TyConName = tcQual iNT_Name SLIT("Int32") int32TyConKey
int8TyConName = tcQual pREL_INT_Name SLIT("Int8") int8TyConKey
int16TyConName = tcQual pREL_INT_Name SLIT("Int16") int16TyConKey
int32TyConName = tcQual pREL_INT_Name SLIT("Int32") int32TyConKey
int64TyConName = tcQual pREL_ADDR_Name SLIT("Int64") int64TyConKey
wordTyConName = tcQual pREL_ADDR_Name SLIT("Word") wordTyConKey
wordDataConName = dataQual pREL_ADDR_Name SLIT("W#") wordDataConKey
word8TyConName = tcQual wORD_Name SLIT("Word8") word8TyConKey
word16TyConName = tcQual wORD_Name SLIT("Word16") word16TyConKey
word32TyConName = tcQual wORD_Name SLIT("Word32") word32TyConKey
wordTyConName = tcQual pREL_ADDR_Name SLIT("Word") wordTyConKey
wordDataConName = dataQual pREL_ADDR_Name SLIT("W#") wordDataConKey
word8TyConName = tcQual pREL_WORD_Name SLIT("Word8") word8TyConKey
word16TyConName = tcQual pREL_WORD_Name SLIT("Word16") word16TyConKey
word32TyConName = tcQual pREL_WORD_Name SLIT("Word32") word32TyConKey
word64TyConName = tcQual pREL_ADDR_Name SLIT("Word64") word64TyConKey
addrTyConName = tcQual pREL_ADDR_Name SLIT("Addr") addrTyConKey
......
......@@ -171,10 +171,6 @@ getPrimRepSize :: PrimRep -> Int
getPrimRepSize DoubleRep = dOUBLE_SIZE -- "words", of course
getPrimRepSize Word64Rep = wORD64_SIZE
getPrimRepSize Int64Rep = iNT64_SIZE
--getPrimRepSize FloatRep = 1
--getPrimRepSize CharRep = 1 -- ToDo: count in bytes?
--getPrimRepSize ArrayRep = 1 -- Listed specifically for *documentation*
--getPrimRepSize ByteArrayRep = 1
getPrimRepSize VoidRep = 0
getPrimRepSize other = 1
......
-----------------------------------------------------------------------
-- $Id: primops.txt,v 1.8 2000/12/11 12:56:14 simonmar Exp $
-- $Id: primops.txt,v 1.9 2000/12/12 12:19:57 simonmar Exp $
--
-- Primitive Operations
--
......@@ -496,35 +496,10 @@ primop Word64ToIntegerOp "word64ToInteger#" GenPrimOp
--- Arrays ---
------------------------------------------------------------------------
primop NewByteArrayOp_Char "newCharArray#" GenPrimOp
primop NewByteArrayOp_Char "newByteArray#" GenPrimOp
Int# -> State# s -> (# State# s, MutByteArr# s #)
with out_of_line = True
primop NewByteArrayOp_Int "newIntArray#" GenPrimOp
Int# -> State# s -> (# State# s, MutByteArr# s #)
with out_of_line = True
primop NewByteArrayOp_Word "newWordArray#" GenPrimOp
Int# -> State# s -> (# State# s, MutByteArr# s #)
with out_of_line = True
primop NewByteArrayOp_Addr "newAddrArray#" GenPrimOp
Int# -> State# s -> (# State# s, MutByteArr# s #)
with out_of_line = True
primop NewByteArrayOp_Float "newFloatArray#" GenPrimOp
Int# -> State# s -> (# State# s, MutByteArr# s #)
with out_of_line = True
primop NewByteArrayOp_Double "newDoubleArray#" GenPrimOp
Int# -> State# s -> (# State# s, MutByteArr# s #)
with out_of_line = True
primop NewByteArrayOp_StablePtr "newStablePtrArray#" GenPrimOp
Int# -> State# s -> (# State# s, MutByteArr# s #)
with out_of_line = True
primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Char# #)
......@@ -547,9 +522,27 @@ primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Int# #)
primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Int64# #)
primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Word# #)
primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
MutByteArr# s -> Int# -> State# s -> (# State# s, Word64# #)
......@@ -583,6 +576,30 @@ primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
MutByteArr# s -> Int# -> StablePtr# a -> State# s -> State# s
with has_side_effects = True
primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
MutByteArr# s -> Int# -> Int# -> State# s -> State# s
with has_side_effects = True
primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
MutByteArr# s -> Int# -> Word# -> State# s -> State# s
with has_side_effects = True
primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
MutByteArr# s -> Int# -> Int# -> State# s -> State# s
with has_side_effects = True
primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
MutByteArr# s -> Int# -> Word# -> State# s -> State# s
with has_side_effects = True
primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
MutByteArr# s -> Int# -> Int# -> State# s -> State# s
with has_side_effects = True
primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
MutByteArr# s -> Int# -> Word# -> State# s -> State# s
with has_side_effects = True
primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
MutByteArr# s -> Int# -> Int64# -> State# s -> State# s
with has_side_effects = True
......@@ -613,6 +630,24 @@ primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
ByteArr# -> Int# -> StablePtr# a
primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
ByteArr# -> Int# -> Int#
primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
ByteArr# -> Int# -> Word#
primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
ByteArr# -> Int# -> Int#
primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
ByteArr# -> Int# -> Word#
primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
ByteArr# -> Int# -> Int#
primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
ByteArr# -> Int# -> Word#
primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
ByteArr# -> Int# -> Int64#
......@@ -641,6 +676,24 @@ primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
Addr# -> Int# -> StablePtr# a
primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
Addr# -> Int# -> Int#
primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
Addr# -> Int# -> Word#
primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
Addr# -> Int# -> Int#
primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
Addr# -> Int# -> Word#
primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
Addr# -> Int# -> Int#
primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
Addr# -> Int# -> Word#
primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
Addr# -> Int# -> Int64#
......@@ -669,6 +722,24 @@ primop IndexOffForeignObjOp_Double "indexDoubleOffForeignObj#" GenPrimOp
primop IndexOffForeignObjOp_StablePtr "indexStablePtrOffForeignObj#" GenPrimOp
ForeignObj# -> Int# -> StablePtr# a
primop IndexOffForeignObjOp_Int8 "indexInt8OffForeignObj#" GenPrimOp
ForeignObj# -> Int# -> Int#
primop IndexOffForeignObjOp_Word8 "indexWord8OffForeignObj#" GenPrimOp
ForeignObj# -> Int# -> Word#
primop IndexOffForeignObjOp_Int16 "indexInt16OffForeignObj#" GenPrimOp
ForeignObj# -> Int# -> Int#
primop IndexOffForeignObjOp_Word16 "indexWord16OffForeignObj#" GenPrimOp
ForeignObj# -> Int# -> Word#
primop IndexOffForeignObjOp_Int32 "indexInt32OffForeignObj#" GenPrimOp
ForeignObj# -> Int# -> Int#
primop IndexOffForeignObjOp_Word32 "indexWord32OffForeignObj#" GenPrimOp
ForeignObj# -> Int# -> Word#
primop IndexOffForeignObjOp_Int64 "indexInt64OffForeignObj#" GenPrimOp
ForeignObj# -> Int# -> Int64#
......@@ -701,6 +772,24 @@ primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
primop ReadOffAddrOp_ForeignObj "readForeignObjOffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, ForeignObj# #)
primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Int# #)
primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Word# #)
primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Int# #)
primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Word# #)
primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Int# #)
primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Word# #)
primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
Addr# -> Int# -> State# s -> (# State# s, Int64# #)
......@@ -740,6 +829,30 @@ primop WriteOffAddrOp_ForeignObj "writeForeignObjOffAddr#" GenPrimOp
Addr# -> Int# -> ForeignObj# -> State# s -> State# s
with has_side_effects = True
primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
Addr# -> Int# -> Int# -> State# s -> State# s
with has_side_effects = True
primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
Addr# -> Int# -> Word# -> State# s -> State# s
with has_side_effects = True
primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
Addr# -> Int# -> Int# -> State# s -> State# s
with has_side_effects = True
primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
Addr# -> Int# -> Word# -> State# s -> State# s
with has_side_effects = True
primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
Addr# -> Int# -> Int# -> State# s -> State# s
with has_side_effects = True
primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
Addr# -> Int# -> Word# -> State# s -> State# s
with has_side_effects = True
primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
Addr# -> Int# -> Int64# -> State# s -> State# s
with has_side_effects = True
......
/* -----------------------------------------------------------------------------
* $Id: PrimOps.h,v 1.69 2000/12/11 12:56:14 simonmar Exp $
* $Id: PrimOps.h,v 1.70 2000/12/12 12:19:57 simonmar Exp $
*
* (c) The GHC Team, 1998-2000
*
......@@ -291,6 +291,12 @@ typedef union {
#define readFloatOffAddrzh(r,a,i) r= PK_FLT((P_) (((StgFloat *)(a)) + i))
#define readDoubleOffAddrzh(r,a,i) r= PK_DBL((P_) (((StgDouble *)(a)) + i))
#define readStablePtrOffAddrzh(r,a,i) r= ((StgStablePtr *)(a))[i]
#define readInt8OffAddrzh(r,a,i) r= ((StgInt8 *)(a))[i]
#define readInt16OffAddrzh(r,a,i) r= ((StgInt16 *)(a))[i]
#define readInt32OffAddrzh(r,a,i) r= ((StgInt32 *)(a))[i]
#define readWord8OffAddrzh(r,a,i) r= ((StgWord8 *)(a))[i]
#define readWord16OffAddrzh(r,a,i) r= ((StgWord16 *)(a))[i]
#define readWord32OffAddrzh(r,a,i) r= ((StgWord32 *)(a))[i]
#ifdef SUPPORT_LONG_LONGS
#define readInt64OffAddrzh(r,a,i) r= ((LI_ *)(a))[i]
#define readWord64OffAddrzh(r,a,i) r= ((LW_ *)(a))[i]
......@@ -305,6 +311,12 @@ typedef union {
#define writeFloatOffAddrzh(a,i,v) ASSIGN_FLT((P_) (((StgFloat *)(a)) + i),v)
#define writeDoubleOffAddrzh(a,i,v) ASSIGN_DBL((P_) (((StgDouble *)(a)) + i),v)
#define writeStablePtrOffAddrzh(a,i,v) ((StgStablePtr *)(a))[i] = (v)
#define writeInt8OffAddrzh(a,i,v) ((StgInt8 *)(a))[i] = (v)
#define writeInt16OffAddrzh(a,i,v) ((StgInt16 *)(a))[i] = (v)
#define writeInt32OffAddrzh(a,i,v) ((StgInt32 *)(a))[i] = (v)
#define writeWord8OffAddrzh(a,i,v) ((StgWord8 *)(a))[i] = (v)
#define writeWord16OffAddrzh(a,i,v) ((StgWord16 *)(a))[i] = (v)
#define writeWord32OffAddrzh(a,i,v) ((StgWord32 *)(a))[i] = (v)
#ifdef SUPPORT_LONG_LONGS
#define writeInt64OffAddrzh(a,i,v) ((LI_ *)(a))[i] = (v)
#define writeWord64OffAddrzh(a,i,v) ((LW_ *)(a))[i] = (v)
......@@ -318,6 +330,12 @@ typedef union {
#define indexFloatOffAddrzh(r,a,i) r= PK_FLT((P_) (((StgFloat *)(a)) + i))
#define indexDoubleOffAddrzh(r,a,i) r= PK_DBL((P_) (((StgDouble *)(a)) + i))
#define indexStablePtrOffAddrzh(r,a,i) r= ((StgStablePtr *)(a))[i]
#define indexInt8OffAddrzh(r,a,i) r= ((StgInt8 *)(a))[i]
#define indexInt16OffAddrzh(r,a,i) r= ((StgInt16 *)(a))[i]
#define indexInt32OffAddrzh(r,a,i) r= ((StgInt32 *)(a))[i]
#define indexWord8OffAddrzh(r,a,i) r= ((StgWord8 *)(a))[i]
#define indexWord16OffAddrzh(r,a,i) r= ((StgWord16 *)(a))[i]
#define indexWord32OffAddrzh(r,a,i) r= ((StgWord32 *)(a))[i]
#ifdef SUPPORT_LONG_LONGS
#define indexInt64OffAddrzh(r,a,i) r= ((LI_ *)(a))[i]
#define indexWord64OffAddrzh(r,a,i) r= ((LW_ *)(a))[i]
......@@ -604,6 +622,12 @@ extern I_ resetGenSymZh(void);
#define readFloatArrayzh(r,a,i) indexFloatOffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readDoubleArrayzh(r,a,i) indexDoubleOffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readStablePtrArrayzh(r,a,i) indexStablePtrOffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readInt8Arrayzh(r,a,i) indexInt8OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readInt16Arrayzh(r,a,i) indexInt16OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readInt32Arrayzh(r,a,i) indexInt32OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readWord8Arrayzh(r,a,i) indexWord8OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readWord16Arrayzh(r,a,i) indexWord16OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readWord32Arrayzh(r,a,i) indexWord32OffAddrzh(r,BYTE_ARR_CTS(a),i)
#ifdef SUPPORT_LONG_LONGS
#define readInt64Arrayzh(r,a,i) indexInt64OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define readWord64Arrayzh(r,a,i) indexWord64OffAddrzh(r,BYTE_ARR_CTS(a),i)
......@@ -622,6 +646,12 @@ extern I_ resetGenSymZh(void);
#define writeDoubleArrayzh(a,i,v) \
ASSIGN_DBL((P_) (((StgDouble *)(BYTE_ARR_CTS(a))) + i),v)
#define writeStablePtrArrayzh(a,i,v) ((StgStablePtr *)(BYTE_ARR_CTS(a)))[i] = (v)
#define writeInt8Arrayzh(a,i,v) ((StgInt8 *)(BYTE_ARR_CTS(a)))[i] = (v)
#define writeInt16Arrayzh(a,i,v) ((StgInt16 *)(BYTE_ARR_CTS(a)))[i] = (v)
#define writeInt32Arrayzh(a,i,v) ((StgInt32 *)(BYTE_ARR_CTS(a)))[i] = (v)
#define writeWord8Arrayzh(a,i,v) ((StgWord8 *)(BYTE_ARR_CTS(a)))[i] = (v)
#define writeWord16Arrayzh(a,i,v) ((StgWord16 *)(BYTE_ARR_CTS(a)))[i] = (v)
#define writeWord32Arrayzh(a,i,v) ((StgWord32 *)(BYTE_ARR_CTS(a)))[i] = (v)
#ifdef SUPPORT_LONG_LONGS
#define writeInt64Arrayzh(a,i,v) ((LI_ *)(BYTE_ARR_CTS(a)))[i] = (v)
#define writeWord64Arrayzh(a,i,v) ((LW_ *)(BYTE_ARR_CTS(a)))[i] = (v)
......@@ -636,6 +666,12 @@ extern I_ resetGenSymZh(void);
#define indexFloatArrayzh(r,a,i) indexFloatOffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexDoubleArrayzh(r,a,i) indexDoubleOffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexStablePtrArrayzh(r,a,i) indexStablePtrOffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexInt8Arrayzh(r,a,i) indexInt8OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexInt16Arrayzh(r,a,i) indexInt16OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexInt32Arrayzh(r,a,i) indexInt32OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexWord8Arrayzh(r,a,i) indexWord8OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexWord16Arrayzh(r,a,i) indexWord16OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexWord32Arrayzh(r,a,i) indexWord32OffAddrzh(r,BYTE_ARR_CTS(a),i)
#ifdef SUPPORT_LONG_LONGS
#define indexInt64Arrayzh(r,a,i) indexInt64OffAddrzh(r,BYTE_ARR_CTS(a),i)
#define indexWord64Arrayzh(r,a,i) indexWord64OffAddrzh(r,BYTE_ARR_CTS(a),i)
......@@ -663,13 +699,7 @@ EXTFUN_RTS(unsafeThawArrayzh_fast);
/* and the out-of-line ones... */
EXTFUN_RTS(newCharArrayzh_fast);
EXTFUN_RTS(newIntArrayzh_fast);
EXTFUN_RTS(newWordArrayzh_fast);
EXTFUN_RTS(newAddrArrayzh_fast);
EXTFUN_RTS(newFloatArrayzh_fast);
EXTFUN_RTS(newDoubleArrayzh_fast);
EXTFUN_RTS(newStablePtrArrayzh_fast);
EXTFUN_RTS(newByteArrayzh_fast);
EXTFUN_RTS(newArrayzh_fast);
/* encoding and decoding of floats/doubles. */
......@@ -936,6 +966,12 @@ EXTFUN_RTS(mkForeignObjzh_fast);
#define indexFloatOffForeignObjzh(r,fo,i) indexFloatOffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexDoubleOffForeignObjzh(r,fo,i) indexDoubleOffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexStablePtrOffForeignObjzh(r,fo,i) indexStablePtrOffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexInt8OffForeignObjzh(r,fo,i) indexInt8OffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexInt16OffForeignObjzh(r,fo,i) indexInt16OffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexInt32OffForeignObjzh(r,fo,i) indexInt32OffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexWord8OffForeignObjzh(r,fo,i) indexWord8OffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexWord16OffForeignObjzh(r,fo,i) indexWord16OffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexWord32OffForeignObjzh(r,fo,i) indexWord32OffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#ifdef SUPPORT_LONG_LONGS
#define indexInt64OffForeignObjzh(r,fo,i) indexInt64OffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
#define indexWord64OffForeignObjzh(r,fo,i) indexWord64OffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
......
% -----------------------------------------------------------------------------
% $Id: PrelArrExtra.lhs,v 1.11 2000/08/29 16:36:23 simonpj Exp $
% $Id: PrelArrExtra.lhs,v 1.12 2000/12/12 12:19:58 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
......@@ -38,7 +38,7 @@ freezeByteArray :: Ix ix => MutableByteArray s ix -> ST s (ByteArray ix)
-- only modifies its destination operand, which is already MutableByteArray.
freezeByteArray (MutableByteArray l u arr) = ST $ \ s ->
let n = sizeofMutableByteArray# arr in
case (newCharArray# n s) of { (# s, newarr #) ->
case (newByteArray# n s) of { (# s, newarr #) ->
case ((unsafeCoerce# memcpy) newarr arr n s) of { (# s, () #) ->
case unsafeFreezeByteArray# newarr s of { (# s, frozen #) ->
(# s, ByteArray l u frozen #) }}}
......
% -----------------------------------------------------------------------------
% $Id: PrelByteArr.lhs,v 1.8 2000/07/07 11:03:58 simonmar Exp $
% $Id: PrelByteArr.lhs,v 1.9 2000/12/12 12:19:58 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
......@@ -76,34 +76,41 @@ newCharArray, newIntArray, newWordArray, newAddrArray, newFloatArray, newDoubleA
newCharArray (l,u) = ST $ \ s# ->
case rangeSize (l,u) of { I# n# ->
case (newCharArray# n# s#) of { (# s2#, barr# #) ->
case (newByteArray# (cHAR_SCALE n#) s#) of { (# s2#, barr# #) ->
(# s2#, MutableByteArray l u barr# #) }}
newIntArray (l,u) = ST $ \ s# ->
case rangeSize (l,u) of { I# n# ->
case (newIntArray# n# s#) of { (# s2#, barr# #) ->
case (newByteArray# (wORD_SCALE n#) s#) of { (# s2#, barr# #) ->
(# s2#, MutableByteArray l u barr# #) }}
newWordArray (l,u) = ST $ \ s# ->
case rangeSize (l,u) of { I# n# ->
case (newWordArray# n# s#) of { (# s2#, barr# #) ->
case (newByteArray# (wORD_SCALE n#) s#) of { (# s2#, barr# #) ->
(# s2#, MutableByteArray l u barr# #) }}
newAddrArray (l,u) = ST $ \ s# ->
case rangeSize (l,u) of { I# n# ->
case (newAddrArray# n# s#) of { (# s2#, barr# #) ->
case (newByteArray# (wORD_SCALE n#) s#) of { (# s2#, barr# #) ->
(# s2#, MutableByteArray l u barr# #) }}
newFloatArray (l,u) = ST $ \ s# ->
case rangeSize (l,u) of { I# n# ->
case (newFloatArray# n# s#) of { (# s2#, barr# #) ->
case (newByteArray# (fLOAT_SCALE n#) s#) of { (# s2#, barr# #) ->
(# s2#, MutableByteArray l u barr# #) }}
newDoubleArray (l,u) = ST $ \ s# ->
case rangeSize (l,u) of { I# n# ->
case (newDoubleArray# n# s#) of { (# s2#, barr# #) ->
case (newByteArray# (dOUBLE_SCALE n#) s#) of { (# s2#, barr# #) ->
(# s2#, MutableByteArray l u barr# #) }}
#include "config.h"
-- Char arrays really contain only 8-bit bytes for compatibility.
cHAR_SCALE n = 1# *# n
wORD_SCALE n = (case SIZEOF_VOID_P :: Int of I# x -> x *# n)
dOUBLE_SCALE n = (case SIZEOF_DOUBLE :: Int of I# x -> x *# n)
fLOAT_SCALE n = (case SIZEOF_FLOAT :: Int of I# x -> x *# n)
readCharArray :: Ix ix => MutableByteArray s ix -> ix -> ST s Char
readIntArray :: Ix ix => MutableByteArray s ix -> ix -> ST s Int
......
......@@ -219,13 +219,7 @@ __export PrelGHC
sameMutableByteArrayzh
newArrayzh
newCharArrayzh
newIntArrayzh
newWordArrayzh
newFloatArrayzh
newDoubleArrayzh
newAddrArrayzh
newStablePtrArrayzh
newByteArrayzh
indexArrayzh
indexCharArrayzh
......@@ -235,7 +229,13 @@ __export PrelGHC
indexDoubleArrayzh
indexAddrArrayzh
indexStablePtrArrayzh
indexInt8Arrayzh
indexInt16Arrayzh
indexInt32Arrayzh
indexInt64Arrayzh
indexWord8Arrayzh
indexWord16Arrayzh
indexWord32Arrayzh
indexWord64Arrayzh
-- indexOffAddrzh
......@@ -246,7 +246,13 @@ __export PrelGHC
indexFloatOffAddrzh
indexDoubleOffAddrzh
indexStablePtrOffAddrzh
indexInt8OffAddrzh
indexInt16OffAddrzh
indexInt32OffAddrzh
indexInt64OffAddrzh
indexWord8OffAddrzh
indexWord16OffAddrzh
indexWord32OffAddrzh
indexWord64OffAddrzh
readCharOffAddrzh
......@@ -256,7 +262,13 @@ __export PrelGHC
readFloatOffAddrzh
readDoubleOffAddrzh
readStablePtrOffAddrzh
readInt8OffAddrzh
readInt16OffAddrzh
readInt32OffAddrzh
readInt64OffAddrzh
readWord8OffAddrzh
readWord16OffAddrzh
readWord32OffAddrzh
readWord64OffAddrzh
writeCharOffAddrzh
......@@ -267,7 +279,13 @@ __export PrelGHC
writeFloatOffAddrzh
writeDoubleOffAddrzh
writeStablePtrOffAddrzh
writeInt8OffAddrzh
writeInt16OffAddrzh
writeInt32OffAddrzh
writeInt64OffAddrzh
writeWord8OffAddrzh
writeWord16OffAddrzh
writeWord32OffAddrzh
writeWord64OffAddrzh
-- indexOffForeignObjzh
......@@ -278,7 +296,13 @@ __export PrelGHC
indexFloatOffForeignObjzh
indexDoubleOffForeignObjzh
indexStablePtrOffForeignObjzh
indexInt8OffForeignObjzh
indexInt16OffForeignObjzh
indexInt32OffForeignObjzh
indexInt64OffForeignObjzh
indexWord8OffForeignObjzh
indexWord16OffForeignObjzh
indexWord32OffForeignObjzh
indexWord64OffForeignObjzh
writeArrayzh
......@@ -289,7 +313,13 @@ __export PrelGHC
writeDoubleArrayzh
writeAddrArrayzh
writeStablePtrArrayzh
writeInt8Arrayzh
writeInt16Arrayzh
writeInt32Arrayzh
writeInt64Arrayzh
writeWord8Arrayzh
writeWord16Arrayzh
writeWord32Arrayzh
writeWord64Arrayzh
readArrayzh
......@@ -300,7 +330,13 @@ __export PrelGHC
readDoubleArrayzh
readAddrArrayzh
readStablePtrArrayzh
readInt8Arrayzh
readInt16Arrayzh
readInt32Arrayzh
readInt64Arrayzh
readWord8Arrayzh
readWord16Arrayzh
readWord32Arrayzh
readWord64Arrayzh
unsafeFreezzeArrayzh -- Note zz in the middle
......
This diff is collapsed.
% ------------------------------------------------------------------------------
% $Id: PrelPack.lhs,v 1.14 2000/07/07 11:03:58 simonmar Exp $
% $Id: PrelPack.lhs,v 1.15 2000/12/12 12:19:58 simonmar Exp $
%
% (c) The University of Glasgow, 1997-2000
%
......@@ -212,7 +212,7 @@ write_ps_array :: MutableByteArray s Int -> Int# -> Char# -> ST s ()
freeze_ps_array :: MutableByteArray s Int -> Int# -> ST s (ByteArray Int)
new_ps_array size = ST $ \ s ->
case (newCharArray# size s) of { (# s2#, barr# #) ->
case (newByteArray# size s) of { (# s2#, barr# #) ->
(# s2#, MutableByteArray bot bot barr# #) }
where
bot = error "new_ps_array"
......
This diff is collapsed.
% ------------------------------------------------------------------------------
% $Id: Time.lhs,v 1.23 2000/08/29 16:38:04 simonpj Exp $
% $Id: Time.lhs,v 1.24 2000/12/12 12:19:58 simonmar Exp $
%
% (c) The University of Glasgow, 1995-2000
%
......@@ -98,7 +98,7 @@ module Time
import PreludeBuiltin
#else
import PrelGHC ( RealWorld, (>#), (<#), (==#),
newIntArray#, readIntArray#,
newByteArray#, readIntArray#,
unsafeFreezeByteArray#,
int2Integer#, negateInt# )
import PrelBase ( Int(..) )
......@@ -108,7 +108,7 @@ import PrelShow ( showList__ )
import PrelPack ( unpackCString, unpackCStringBA,
new_ps_array, freeze_ps_array
)
import PrelByteArr ( MutableByteArray(..) )
import PrelByteArr ( MutableByteArray(..), wORD_SCALE )
import PrelHandle ( Bytes )
import PrelAddr ( Addr )
......@@ -280,7 +280,7 @@ cvtUnsigned arr = primReadInt64Array arr 0
#else
malloc1 :: IO (MutableByteArray RealWorld Int)
malloc1 = IO $ \ s# ->
case newIntArray# 1# s# of
case newByteArray# 1# s# of
(# s2#, barr# #) -> (# s2#, MutableByteArray bot bot barr# #)
where
bot = error "Time.malloc1"
......@@ -550,7 +550,7 @@ allocChars (I# size#) = stToIO (new_ps_array size#)
allocWords :: Int -> IO (MutableByteArray RealWorld Int)
allocWords (I# size#) = IO $ \ s# ->
case newIntArray# size# s# of
case newByteArray# (wORD_SCALE size#) s# of
(# s2#, barr# #) ->
(# s2#, MutableByteArray bot bot barr# #)
where
......
/* -----------------------------------------------------------------------------
* $Id: Linker.c,v 1.2 2000/11/13 14:40:37 simonmar Exp $
* $Id: Linker.c,v 1.3 2000/12/12 12:19:57 simonmar Exp $
*
* (c) The GHC Team, 2000
*
......@@ -172,12 +172,7 @@ static int ocResolve_PEi386 ( ObjectCode* oc );
SymX(gcdIntegerzh_fast) \
SymX(newArrayzh_fast) \
SymX(unsafeThawArrayzh_fast) \
SymX(newDoubleArrayzh_fast) \
SymX(newFloatArrayzh_fast) \
SymX(newAddrArrayzh_fast) \
SymX(newWordArrayzh_fast) \
SymX(newIntArrayzh_fast) \
SymX(newCharArrayzh_fast) \
SymX(newByteArrayzh_fast) \
SymX(newMutVarzh_fast) \
SymX(quotRemIntegerzh_fast) \
SymX(quotIntegerzh_fast) \