X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FSchedule.c;h=a7a0f33872ff1048c68a1673e07fff7a3d351f85;hb=e576ba5d31fbae54c43e88316fb0dbdba9cbd4ff;hp=f67fcd98571f93292592dba50cea35af430db9a9;hpb=f4b8374442162769ea87c24bf90a0f86a2fdd9b7;p=ghc-hetmet.git diff --git a/rts/Schedule.c b/rts/Schedule.c index f67fcd9..a7a0f33 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -588,6 +588,10 @@ run_thread: prev_what_next = t->what_next; errno = t->saved_errno; +#if mingw32_HOST_OS + SetLastError(t->saved_winerror); +#endif + cap->in_haskell = rtsTrue; dirtyTSO(t); @@ -637,6 +641,10 @@ run_thread: // XXX: possibly bogus for SMP because this thread might already // be running again, see code below. t->saved_errno = errno; +#if mingw32_HOST_OS + // Similarly for Windows error code + SetLastError(t->saved_winerror); +#endif #if defined(THREADED_RTS) // If ret is ThreadBlocked, and this Task is bound to the TSO that @@ -1810,7 +1818,7 @@ scheduleHandleThreadFinished (Capability *cap STG_UNUSED, Task *task, StgTSO *t) (unsigned long)t->id, whatNext_strs[t->what_next]); /* Inform the Hpc that a thread has finished */ - hs_hpc_event("Thread Finished",t); + hs_hpc_thread_finished_event(t); #if defined(GRAN) endThread(t, CurrentProc); // clean-up the thread @@ -2283,9 +2291,17 @@ void * suspendThread (StgRegTable *reg) { Capability *cap; - int saved_errno = errno; + int saved_errno; StgTSO *tso; Task *task; +#if mingw32_HOST_OS + StgWord32 saved_winerror; +#endif + + saved_errno = errno; +#if mingw32_HOST_OS + saved_winerror = GetLastError(); +#endif /* assume that *reg is a pointer to the StgRegTable part of a Capability. */ @@ -2330,6 +2346,9 @@ suspendThread (StgRegTable *reg) #endif errno = saved_errno; +#if mingw32_HOST_OS + SetLastError(saved_winerror); +#endif return task; } @@ -2338,8 +2357,16 @@ resumeThread (void *task_) { StgTSO *tso; Capability *cap; - int saved_errno = errno; Task *task = task_; + int saved_errno; +#if mingw32_HOST_OS + StgWord32 saved_winerror; +#endif + + saved_errno = errno; +#if mingw32_HOST_OS + saved_winerror = GetLastError(); +#endif cap = task->cap; // Wait for permission to re-enter the RTS with the result. @@ -2367,6 +2394,9 @@ resumeThread (void *task_) cap->r.rCurrentTSO = tso; cap->in_haskell = rtsTrue; errno = saved_errno; +#if mingw32_HOST_OS + SetLastError(saved_winerror); +#endif /* We might have GC'd, mark the TSO dirty again */ dirtyTSO(tso);