X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=opt%2Fnothread%2Fcall_once.c;h=3bdca049a2f6d3e1dd2734a458d89946a3338299;hp=be1ed2e07e4e956ddaa1cd87f1313c2bbd5fcd02;hb=da0f3f353d417fed71f358a48d5d5394145e460d;hpb=5155ca96295a12b4857fc0e6a9629cc43a9a85fa diff --git a/opt/nothread/call_once.c b/opt/nothread/call_once.c index be1ed2e..3bdca04 100644 --- a/opt/nothread/call_once.c +++ b/opt/nothread/call_once.c @@ -1,26 +1,31 @@ +#ifndef REGTEST #include void _PDCLIB_call_once(_PDCLIB_once_flag *flag, void (*func)(void)) { - if(*flag != _PDCLIB_ONCE_FLAG_DONE) { + if(!_PDCLIB_ONCE_FLAG_IS_DONE(flag)) { func(); - *flag = _PDCLIB_ONCE_FLAG_DONE; + *flag = 1; } } +#endif #ifdef TEST -#include <_PDCLIB_test.h> +#include "_PDCLIB_test.h" +#ifndef REGTEST static int count = 0; -once_flag once = ONCE_FLAG_INIT; +static once_flag once = ONCE_FLAG_INIT; static void do_once(void) { count++; } +#endif int main( void ) { +#ifndef REGTEST TESTCASE(count == 0); call_once(&once, do_once); TESTCASE(count == 1); @@ -28,6 +33,7 @@ int main( void ) TESTCASE(count == 1); do_once(); TESTCASE(count == 2); +#endif return TEST_RESULTS; }