]> pd.if.org Git - pdclib.old/blobdiff - opt/nothread/call_once.c
opt nothread: Fix call_once to match recent changes to the implementation method
[pdclib.old] / opt / nothread / call_once.c
index be1ed2e07e4e956ddaa1cd87f1313c2bbd5fcd02..cce9a499493ad3c4eb80e70b34a37b34299842e9 100644 (file)
@@ -1,26 +1,31 @@
+#ifndef REGTEST\r
 #include <threads.h>\r
 \r
 void _PDCLIB_call_once(_PDCLIB_once_flag *flag, void (*func)(void))\r
 {\r
-       if(*flag != _PDCLIB_ONCE_FLAG_DONE) {\r
+       if(!_PDCLIB_ONCE_FLAG_IS_DONE(flag)) {\r
                func();\r
-               *flag = _PDCLIB_ONCE_FLAG_DONE;\r
+               *flag = 1;\r
        }\r
 }\r
+#endif\r
 \r
 #ifdef TEST\r
 #include <_PDCLIB_test.h>\r
 \r
+#ifndef REGTEST\r
 static int count = 0;\r
-once_flag once = ONCE_FLAG_INIT;\r
+static once_flag once = ONCE_FLAG_INIT;\r
 \r
 static void do_once(void)\r
 {\r
     count++;\r
 }\r
+#endif\r
 \r
 int main( void )\r
 {\r
+#ifndef REGTEST\r
     TESTCASE(count == 0);\r
     call_once(&once, do_once);\r
     TESTCASE(count == 1);\r
@@ -28,6 +33,7 @@ int main( void )
     TESTCASE(count == 1);\r
     do_once();\r
     TESTCASE(count == 2);\r
+#endif\r
     return TEST_RESULTS;\r
 }\r
 \r