X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FInterpreter.c;h=888f3b8f2dcd7f34c33de578fb420a312aa4b0c5;hb=1820f42c87e521f5043fabf98d62c149c87282d8;hp=7f408d7cc1abe3ca5f4f612a6430950a57ec5e71;hpb=5a227dba7c8cc5517783ef87f046b0a3b114449b;p=ghc-hetmet.git diff --git a/ghc/rts/Interpreter.c b/ghc/rts/Interpreter.c index 7f408d7..888f3b8 100644 --- a/ghc/rts/Interpreter.c +++ b/ghc/rts/Interpreter.c @@ -26,6 +26,11 @@ #include "Disassembler.h" #include "Interpreter.h" +#include /* for memcpy */ +#ifdef HAVE_ERRNO_H +#include +#endif + /* -------------------------------------------------------------------------- * The bytecode interpreter @@ -1172,6 +1177,9 @@ run_BCO: memcpy(arguments, Sp, sizeof(W_) * stk_offset); #endif + // Restore the Haskell thread's current value of errno + errno = cap->r.rCurrentTSO->saved_errno; + // There are a bunch of non-ptr words on the stack (the // ccall args, the ccall fun address and space for the // result), which we need to cover with an info table @@ -1208,6 +1216,9 @@ run_BCO: LOAD_STACK_POINTERS; Sp += ret_dyn_size; + // Save the Haskell thread's current value of errno + cap->r.rCurrentTSO->saved_errno = errno; + #ifdef RTS_SUPPORTS_THREADS // Threaded RTS: // Copy the "arguments", which might include a return value,