X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=platform%2Fwin32%2Fcrt0.c;h=533ee98b862785cb6cabaee6be391629bf7bedd6;hb=2d43dbb1c70aee6c3474c254c0a2302ef39c0c7a;hp=d32a6ac703976a8e2793a6c04d5be482b9aba575;hpb=99677c35ae2bfd651274191143e140d730fc9925;p=pdclib.old diff --git a/platform/win32/crt0.c b/platform/win32/crt0.c index d32a6ac..533ee98 100644 --- a/platform/win32/crt0.c +++ b/platform/win32/crt0.c @@ -5,6 +5,9 @@ #include #include // Watcom bug: winnt.h assumes string.h defines wchar_t #include +#include <_PDCLIB_io.h> +#include <_PDCLIB_locale.h> +#include <_PDCLIB_clocale.h> static char ** argvToAnsi( wchar_t ** wargv, int argc ) { @@ -114,11 +117,21 @@ void __cdecl mainCRTStartup( void ) wargv = CommandLineToArgvW(cl, &argc); argv = argvToAnsi(wargv, argc); + _PDCLIB_initclocale( &_PDCLIB_global_locale ); + + 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);