3 /* atexit( void (*)( void ) )
5 This file is part of the Public Domain C Library (PDCLib).
6 Permission is granted to use, modify, and / or redistribute at will.
13 extern void (*_PDCLIB_regstack[])( void );
14 extern size_t _PDCLIB_regptr;
16 int atexit( void (*func)( void ) )
18 if ( _PDCLIB_regptr == 0 )
24 _PDCLIB_regstack[ --_PDCLIB_regptr ] = func;
32 #include <_PDCLIB_test.h>
35 static int flags[ 32 ];
37 static void counthandler( void )
40 flags[ count ] = count;
44 static void checkhandler( void )
46 for ( int i = 0; i < 31; ++i )
48 assert( flags[ i ] == i );
54 TESTCASE( atexit( &checkhandler ) == 0 );
55 for ( int i = 0; i < 31; ++i )
57 TESTCASE( atexit( &counthandler ) == 0 );