diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-07-16 10:56:54 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-07-16 10:56:54 -0400 |
commit | c0979cc53442b3a6202acab9cf164f0a4beea0b7 (patch) | |
tree | d08b956887e69f9bd2959f1ac75cc2a2182f9a32 /rts/RtsStartup.c | |
parent | ae11bdfd98a10266bfc7de9e16b500be220307ac (diff) | |
parent | 2143c49273d7d87ee2f3ef1211856d60b1427af1 (diff) | |
download | haskell-c0979cc53442b3a6202acab9cf164f0a4beea0b7.tar.gz |
Merge remote-tracking branch 'origin/wip/winio'
Diffstat (limited to 'rts/RtsStartup.c')
-rw-r--r-- | rts/RtsStartup.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index f73d0bd742..a52c02190e 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -46,11 +46,13 @@ #endif #if defined(mingw32_HOST_OS) && !defined(THREADED_RTS) -#include "win32/AsyncIO.h" +#include "win32/AsyncMIO.h" +#include "win32/AsyncWinIO.h" #endif #if defined(mingw32_HOST_OS) #include <fenv.h> +#include <windows.h> #else #include "posix/TTY.h" #endif @@ -120,6 +122,21 @@ void fpreset(void) { _fpreset(); } #endif + +/* Set the console's CodePage to UTF-8 if using the new I/O manager and the CP + is still the default one. */ +static void +initConsoleCP (void) +{ + /* Check if the codepage is still the system default ANSI codepage. */ + if (GetConsoleCP () == GetOEMCP ()) { + if (! SetConsoleCP (CP_UTF8)) + errorBelch ("Unable to set console CodePage, Unicode output may be " + "garbled.\n"); + else + IF_DEBUG (scheduler, debugBelch ("Codepage set to UTF-8.\n")); + } +} #endif /* ----------------------------------------------------------------------------- @@ -220,6 +237,12 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config) #endif /* DEBUG */ } + /* Initialize console Codepage. */ +#if defined(mingw32_HOST_OS) + if (is_io_mng_native_p()) + initConsoleCP(); +#endif + /* Initialise the stats department, phase 1 */ initStats1(); @@ -277,10 +300,13 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config) getStablePtr((StgPtr)nestedAtomically_closure); getStablePtr((StgPtr)runSparks_closure); getStablePtr((StgPtr)ensureIOManagerIsRunning_closure); + getStablePtr((StgPtr)interruptIOManager_closure); getStablePtr((StgPtr)ioManagerCapabilitiesChanged_closure); #if !defined(mingw32_HOST_OS) getStablePtr((StgPtr)blockedOnBadFD_closure); getStablePtr((StgPtr)runHandlersPtr_closure); +#else + getStablePtr((StgPtr)processRemoteCompletion_closure); #endif // Initialize the top-level handler system @@ -316,7 +342,10 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config) #endif #if defined(mingw32_HOST_OS) && !defined(THREADED_RTS) - startupAsyncIO(); + if (is_io_mng_native_p()) + startupAsyncWinIO(); + else + startupAsyncIO(); #endif x86_init_fpu(); @@ -498,7 +527,10 @@ hs_exit_(bool wait_foreign) #endif #if defined(mingw32_HOST_OS) && !defined(THREADED_RTS) - shutdownAsyncIO(wait_foreign); + if (is_io_mng_native_p()) + shutdownAsyncWinIO(wait_foreign); + else + shutdownAsyncIO(wait_foreign); #endif /* free hash table storage */ |