diff options
-rw-r--r-- | rts/Schedule.c | 4 | ||||
-rw-r--r-- | rts/StgCRun.c | 12 | ||||
-rw-r--r-- | rts/StgRun.h | 4 |
3 files changed, 20 insertions, 0 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c index 45959a92eb..50e0663577 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -581,6 +581,10 @@ static void schedulePreLoop(void) { // initialisation for scheduler - what cannot go into initScheduler() + +#if defined(mingw32_HOST_OS) + win32AllocStack(); +#endif } /* ----------------------------------------------------------------------------- diff --git a/rts/StgCRun.c b/rts/StgCRun.c index 54ac04151c..69d9549f6e 100644 --- a/rts/StgCRun.c +++ b/rts/StgCRun.c @@ -192,6 +192,18 @@ StgRunIsImplementedInAssembler(void) ); } +#if defined(mingw32_HOST_OS) +// On windows the stack has to be allocated 4k at a time, otherwise +// we get a segfault. The C compiler knows how to do this (it calls +// _alloca()), so we make sure that we can allocate as much stack as +// we need: +StgWord8 *win32AllocStack(void) +{ + StgWord8 stack[RESERVED_C_STACK_BYTES + 16 + 12]; + return stack; +} +#endif + #endif /* ---------------------------------------------------------------------------- diff --git a/rts/StgRun.h b/rts/StgRun.h index f277097df7..71b92e2d88 100644 --- a/rts/StgRun.h +++ b/rts/StgRun.h @@ -11,4 +11,8 @@ RTS_PRIVATE StgRegTable * StgRun (StgFunPtr f, StgRegTable *basereg); +#if defined(mingw32_HOST_OS) +StgWord8 *win32AllocStack(void); +#endif + #endif /* STGRUN_H */ |