X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=opt%2Fnothread%2Fcall_once.c;h=cce9a499493ad3c4eb80e70b34a37b34299842e9;hb=7ef2d8e3f973420b1b717525d643e47337557938;hp=be1ed2e07e4e956ddaa1cd87f1313c2bbd5fcd02;hpb=bb22ff7ecd9fe8f4641484df12ad629cd8ee27ac;p=pdclib.old diff --git a/opt/nothread/call_once.c b/opt/nothread/call_once.c index be1ed2e..cce9a49 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> +#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; }