]> pd.if.org Git - pdclib.old/blobdiff - platform/win32/crt0.c
PDCLIB-15 PDCLIB-16:
[pdclib.old] / platform / win32 / crt0.c
index 076e76e464423df47ae0d5320407bf5b73f301f7..7da2a8151e2ad3b279e0c9005d45b8b56b22c919 100644 (file)
@@ -2,6 +2,7 @@
 #include <stdlib.h>\r
 #include <stdio.h>\r
 #include <signal.h>\r
+#include <threads.h>\r
 #include <wchar.h> // Watcom bug: winnt.h assumes string.h defines wchar_t\r
 #include <windows.h>\r
 \r
@@ -112,6 +113,14 @@ void __cdecl mainCRTStartup( void )
     cl    = GetCommandLineW();\r
     wargv = CommandLineToArgvW(cl, &argc);\r
     argv  = argvToAnsi(wargv, argc);\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
+    }\r
+\r
     atexit(freeArgs);\r
 \r
     int exitStatus = main(argc, argv, NULL);\r