globalvars: get rid of `trap_map'
authorBernhard Urban <lewurm@gmail.com>
Thu, 17 May 2012 21:35:02 +0000 (23:35 +0200)
committerBernhard Urban <lewurm@gmail.com>
Thu, 17 May 2012 21:35:31 +0000 (23:35 +0200)
we can do that differently (still ugly though)

Mate/ClassPool.hs
ffi/trap.c

index 45a8fffb36e28411c423c20422d18eda80398d11..b7c394c8f8b54b65df9975a6dd835a54064adaba 100644 (file)
@@ -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
index 8a4db6f0400b332cc85f09501e5d2080b3217cf6..5230c0cc7c1c9f8a867a194def8f833540f71226 100644 (file)
@@ -22,7 +22,7 @@
 #include <sys/ucontext.h>
 
 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);