1 /* atexit( void (*)( void ) )
3 This file is part of the Public Domain C Library (PDCLib).
4 Permission is granted to use, modify, and / or redistribute at will.
11 extern void (*_PDCLIB_exitstack[])( void );
12 extern size_t _PDCLIB_exitptr;
14 int atexit( void (*func)( void ) )
16 if ( _PDCLIB_exitptr == 0 )
22 _PDCLIB_exitstack[ --_PDCLIB_exitptr ] = func;
31 #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 );