]> pd.if.org Git - pdclib.old/commitdiff
win32: crt0: initialize locale TSS
authorOwen Shepherd <owen.shepherd@e43.eu>
Mon, 7 Jan 2013 15:23:45 +0000 (15:23 +0000)
committerOwen Shepherd <owen.shepherd@e43.eu>
Mon, 7 Jan 2013 15:23:45 +0000 (15:23 +0000)
platform/win32/crt0.c

index d32a6ac703976a8e2793a6c04d5be482b9aba575..bead33206c1541a8f782a52cca59abb2c6c68ce5 100644 (file)
@@ -5,6 +5,8 @@
 #include <threads.h>\r
 #include <wchar.h> // Watcom bug: winnt.h assumes string.h defines wchar_t\r
 #include <windows.h>\r
+#include <_PDCLIB_io.h>\r
+#include <_PDCLIB_locale.h>\r
 \r
 static char ** argvToAnsi( wchar_t ** wargv, int argc )\r
 {\r
@@ -114,11 +116,19 @@ void __cdecl mainCRTStartup( void )
     wargv = CommandLineToArgvW(cl, &argc);\r
     argv  = argvToAnsi(wargv, argc);\r
 \r
+    if(tss_create(&_PDCLIB_locale_tss, (tss_dtor_t) freelocale) \r
+            != thrd_success) {\r
+        fputs( "Error during C runtime initialization: "\r
+               "Unable to allocate locale TLS", stderr );\r
+        exit( EXIT_FAILURE );\r
+    }\r
+\r
     if(        mtx_init(&stdin->lock, mtx_recursive) != thrd_success \r
             || mtx_init(&stdout->lock, mtx_recursive) != thrd_success\r
             || mtx_init(&stderr->lock, mtx_recursive) != thrd_success ) {\r
         fputs( "Error during C runtime initialization: "\r
             "Unable to allocate stdio mutex", stderr );\r
+        exit( EXIT_FAILURE );\r
     }\r
 \r
     atexit(freeArgs);\r