From: Bernhard Urban Date: Thu, 17 May 2012 21:35:02 +0000 (+0200) Subject: globalvars: get rid of `trap_map' X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mate.git;a=commitdiff_plain;h=ee844c4902a9511762ae291b2cd9ac21c13f524c globalvars: get rid of `trap_map' we can do that differently (still ugly though) --- diff --git a/Mate/ClassPool.hs b/Mate/ClassPool.hs index 45a8fff..b7c394c 100644 --- a/Mate/ClassPool.hs +++ b/Mate/ClassPool.hs @@ -84,10 +84,10 @@ getObjectSize path = do -- one slot for "method-table-ptr" return $ (1 + fsize) * 4 -foreign export ccall getStaticFieldAddr :: CUInt -> Ptr () -> IO CUInt -getStaticFieldAddr :: CUInt -> Ptr () -> IO CUInt -getStaticFieldAddr from ptr_trapmap = do - trapmap <- ptr2trapmap ptr_trapmap +foreign export ccall getStaticFieldAddr :: CUInt -> IO CUInt +getStaticFieldAddr :: CUInt -> IO CUInt +getStaticFieldAddr from = do + trapmap <- get_trapmap >>= ptr2trapmap let w32_from = fromIntegral from let sfi = trapmap M.! w32_from case sfi of diff --git a/ffi/trap.c b/ffi/trap.c index 8a4db6f..5230c0c 100644 --- a/ffi/trap.c +++ b/ffi/trap.c @@ -22,7 +22,7 @@ #include unsigned int getMethodEntry(unsigned int, unsigned int); -unsigned int getStaticFieldAddr(unsigned int, void*); +unsigned int getStaticFieldAddr(unsigned int); unsigned int getTrapType(unsigned int, unsigned int); unsigned int mallocObject(int); @@ -131,7 +131,7 @@ void sigsegvtrap(int nSignal, siginfo_t *info, void *ctx) dprintf("staticfieldtrap: something is wrong here. abort\n"); exit(0); } - unsigned int patchme = getStaticFieldAddr(from, trap_map); + unsigned int patchme = getStaticFieldAddr(from); dprintf(" to_patch: 0x%08x\n", (unsigned int) to_patch); dprintf("*to_patch: 0x%08x\n", *to_patch);