X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;ds=sidebyside;f=functions%2Fstdlib%2Fatexit.c;h=14363566a8147dba4f6c6c7962a9c62ea26eb61f;hb=5c311ed91d33b96bd39b80bc16cbe4951de35ac6;hp=573e4ba68bf706590b71e377ba0e21cbf45eae46;hpb=064097d5ed6eb8c2cfd337c29ac3ebc471e557b8;p=pdclib diff --git a/functions/stdlib/atexit.c b/functions/stdlib/atexit.c index 573e4ba..1436356 100644 --- a/functions/stdlib/atexit.c +++ b/functions/stdlib/atexit.c @@ -12,13 +12,6 @@ #ifndef REGTEST -/* TODO: Required by both atexit() and exit(). */ -struct _PDCLIB_exitfunc_t -{ - struct _PDCLIB_exitfunc_t * next; - void (*func)( void ); -}; - extern struct _PDCLIB_exitfunc_t * regstack; int atexit( void (*func)( void ) ) @@ -41,12 +34,33 @@ int atexit( void (*func)( void ) ) #ifdef TEST #include <_PDCLIB_test.h> +#include + +static int flags[ 32 ]; + +static void counthandler() +{ + static int rc = 0; + flags[ rc ] = rc; + ++rc; +} + +static void checkhandler() +{ + for ( int i = 0; i < 31; ++i ) + { + assert( flags[ i ] == i ); + } +} int main() { - int NO_TESTDRIVER = 0; BEGIN_TESTS; - TESTCASE( NO_TESTDRIVER ); + TESTCASE( atexit( &checkhandler ) == 0 ); + for ( int i = 0; i < 31; ++i ) + { + TESTCASE( atexit( &counthandler ) == 0 ); + } return TEST_RESULTS; }