]> pd.if.org Git - pdclib/blobdiff - functions/stdio/_PDCLIB_fdopen.c
PDCLIB-16: Add _unlocked variations of all I/O routines; move work into these versions
[pdclib] / functions / stdio / _PDCLIB_fdopen.c
index 85563270fa5029c7d4dbe73971c8bb273f375f30..c628ebcd1e5da4ebf48131e2b9771c47c4d0cce1 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef REGTEST\r
 #include <_PDCLIB_glue.h>\r
 #include <string.h>\r
+#include <threads.h>\r
 \r
 extern struct _PDCLIB_file_t * _PDCLIB_filelist;\r
 \r
@@ -39,6 +40,12 @@ struct _PDCLIB_file_t * _PDCLIB_fdopen( _PDCLIB_fd_t fd,
         /* no memory */\r
         return NULL;\r
     }\r
+\r
+    if(mtx_init(&rc->lock, mtx_recursive) != thrd_success) {\r
+        free(rc);\r
+        return NULL;\r
+    }\r
+\r
     rc->status = mode;\r
     rc->handle = fd;\r
     /* Setting pointers into the memory block allocated above */\r