From 39358ba4521f18f66c118f3d9bcbeee6f6a2c87f Mon Sep 17 00:00:00 2001 From: Owen Shepherd Date: Mon, 7 Jan 2013 15:23:45 +0000 Subject: [PATCH] win32: crt0: initialize locale TSS --- platform/win32/crt0.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/platform/win32/crt0.c b/platform/win32/crt0.c index d32a6ac..bead332 100644 --- a/platform/win32/crt0.c +++ b/platform/win32/crt0.c @@ -5,6 +5,8 @@ #include #include // Watcom bug: winnt.h assumes string.h defines wchar_t #include +#include <_PDCLIB_io.h> +#include <_PDCLIB_locale.h> static char ** argvToAnsi( wchar_t ** wargv, int argc ) { @@ -114,11 +116,19 @@ void __cdecl mainCRTStartup( void ) wargv = CommandLineToArgvW(cl, &argc); argv = argvToAnsi(wargv, argc); + if(tss_create(&_PDCLIB_locale_tss, (tss_dtor_t) freelocale) + != thrd_success) { + fputs( "Error during C runtime initialization: " + "Unable to allocate locale TLS", stderr ); + exit( EXIT_FAILURE ); + } + if( mtx_init(&stdin->lock, mtx_recursive) != thrd_success || mtx_init(&stdout->lock, mtx_recursive) != thrd_success || mtx_init(&stderr->lock, mtx_recursive) != thrd_success ) { fputs( "Error during C runtime initialization: " "Unable to allocate stdio mutex", stderr ); + exit( EXIT_FAILURE ); } atexit(freeArgs); -- 2.40.0