From: Harald Steinlechner Date: Fri, 18 May 2012 20:00:05 +0000 (+0200) Subject: scratch/ffiTest: removed export X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mate.git;a=commitdiff_plain;h=963d89d9e68f1db264e32afb681f5f2064aa82f4 scratch/ffiTest: removed export --- diff --git a/scratch/ffiTest/mate_support.c b/scratch/ffiTest/mate_support.c index 7ca8919..22cfdfc 100644 --- a/scratch/ffiTest/mate_support.c +++ b/scratch/ffiTest/mate_support.c @@ -28,31 +28,12 @@ void trap(int nSignal, siginfo_t *info, void *ctx) mcontext_t *mctx = &((ucontext_t *) ctx)->uc_mcontext; unsigned int from = (unsigned int) mctx->gregs[REG_EIP]; - mateTrapHandler(nSignal, info, ctx, from); + //mateTrapHandler(nSignal, info, ctx, from); printf("from: 0x%08x\n", from); exit(0); } -void registerSignalHandlers(void) -{ - printf("registering\n"); - struct sigaction illaction; - illaction.sa_sigaction = trap; - sigemptyset(&illaction.sa_mask); - illaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; - sigaction(SIGILL, &illaction, NULL); - - -/* - struct sigaction segvaction; - segvaction.sa_sigaction = trap; - sigemptyset(&segvaction.sa_mask); - segvaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; - sigaction(SIGSEGV, &segvaction, NULL); -*/ -} - void registerSignalHandlers2(void (*f)(int, siginfo_t*,void*)) { diff --git a/scratch/ffiTest/prototypes.h b/scratch/ffiTest/prototypes.h index 55b7903..d9ba80c 100644 --- a/scratch/ffiTest/prototypes.h +++ b/scratch/ffiTest/prototypes.h @@ -1,8 +1,8 @@ -extern void registerSignalHandlers(void); -extern void mateTrapHandler(unsigned int signal, +//extern void registerSignalHandlers(void); +/*extern void mateTrapHandler(unsigned int signal, siginfo_t *sigInfo, void *ctx, unsigned int eip); - +*/ extern void registerSignalHandlers2(void (*f)(int, siginfo_t*,void*)); diff --git a/scratch/ffiTest/trapTest.hs b/scratch/ffiTest/trapTest.hs index 409c9a3..21e3719 100644 --- a/scratch/ffiTest/trapTest.hs +++ b/scratch/ffiTest/trapTest.hs @@ -22,8 +22,6 @@ foreign import ccall "static sys/mman.h" foreign import ccall "static stdlib.h" memalign :: CUInt -> CUInt -> IO (Ptr a) -foreign import ccall safe "prototypes.h" - registerSignalHandlers :: IO () foreign import ccall "wrapper" wrap :: (CUInt -> Ptr SigInfo -> Ptr Context -> IO ()) -> IO (FunPtr (CUInt -> Ptr SigInfo -> Ptr Context -> IO ())) @@ -31,9 +29,6 @@ foreign import ccall "wrapper" foreign import ccall "prototypes.h" registerSignalHandlers2 :: FunPtr (CUInt -> Ptr SigInfo -> Ptr Context -> IO ()) -> IO () -foreign export ccall - mateTrapHandler :: CUInt -> Ptr SigInfo -> Ptr Context -> CUInt -> IO () - type SigInfo = () type Context = () @@ -49,6 +44,7 @@ runMateKernel :: AppDomain -> IO () runMateKernel _ = do compileAndRun + -- use FFI to unpack sigInfo and ctx.... handler mateCtx signal sigInfo ctx = do putStr "handler got me." @@ -95,13 +91,3 @@ compileAndRun = do senseless :: IO Int senseless = getStdRandom (randomR (1,100)) - - -mateTrapHandler :: CUInt -> Ptr SigInfo -> Ptr Context -> CUInt -> IO () -mateTrapHandler signal sigInfo ctx eip = do - putStr "mateTrapHandler says: " - let eip' = (fromIntegral eip) :: Int - printf "source, eip: 0x%08x" eip' - print eip' - -