diff options
author | Ben.Lippmeier@anu.edu.au <unknown> | 2009-03-31 04:51:45 +0000 |
---|---|---|
committer | Ben.Lippmeier@anu.edu.au <unknown> | 2009-03-31 04:51:45 +0000 |
commit | adaaa7f79e78d4c799ec44ee1878d09405382b64 (patch) | |
tree | 3f7df1b874292bb96722ed7424723478c55f81c5 /rts/RtsAPI.c | |
parent | 0bff9925654d75ef0fd8fb5d48b700337ebd8f47 (diff) | |
download | haskell-adaaa7f79e78d4c799ec44ee1878d09405382b64.tar.gz |
SPARC: Fix ffi019 split load/store of HsInt64 into two parts to respect alignment constraints
Diffstat (limited to 'rts/RtsAPI.c')
-rw-r--r-- | rts/RtsAPI.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/rts/RtsAPI.c b/rts/RtsAPI.c index a499d65870..911e703b75 100644 --- a/rts/RtsAPI.c +++ b/rts/RtsAPI.c @@ -152,6 +152,31 @@ rts_mkWord32 (Capability *cap, HsWord32 w) return p; } + +#ifdef sparc_HOST_ARCH +/* The closures returned by allocateLocal are only guaranteed to be 32 bit + aligned, because that's the size of pointers. SPARC v9 can't do + misaligned loads/stores, so we have to write the 64bit word in chunks */ + +HaskellObj +rts_mkWord64 (Capability *cap, HsWord64 w_) +{ + StgWord64 w = (StgWord64)w_; + StgWord32 *tmp; + + StgClosure *p = (StgClosure *)allocateLocal(cap,CONSTR_sizeW(0,2)); + /* see mk_Int8 comment */ + SET_HDR(p, W64zh_con_info, CCS_SYSTEM); + + tmp = (StgWord32*)&(p->payload[0]); + + tmp[0] = (StgWord32)((StgWord64)w >> 32); + tmp[1] = (StgWord32)w; /* truncate high 32 bits */ + return p; +} + +#else + HaskellObj rts_mkWord64 (Capability *cap, HsWord64 w) { @@ -165,6 +190,9 @@ rts_mkWord64 (Capability *cap, HsWord64 w) return p; } +#endif + + HaskellObj rts_mkFloat (Capability *cap, HsFloat f) { @@ -364,6 +392,26 @@ rts_getWord32 (HaskellObj p) } +#ifdef sparc_HOST_ARCH +/* The closures returned by allocateLocal are only guaranteed to be 32 bit + aligned, because that's the size of pointers. SPARC v9 can't do + misaligned loads/stores, so we have to write the 64bit word in chunks */ + +HsWord64 +rts_getWord64 (HaskellObj p) +{ + HsInt32* tmp; + // See comment above: + // ASSERT(p->header.info == I64zh_con_info || + // p->header.info == I64zh_static_info); + tmp = (HsInt32*)&(UNTAG_CLOSURE(p)->payload[0]); + + HsInt64 i = (HsWord64)((HsWord64)(tmp[0]) << 32) | (HsWord64)tmp[1]; + return i; +} + +#else + HsWord64 rts_getWord64 (HaskellObj p) { @@ -375,6 +423,9 @@ rts_getWord64 (HaskellObj p) return *tmp; } +#endif + + HsFloat rts_getFloat (HaskellObj p) { |