/* exit( int )12This file is part of the Public Domain C Library (PDCLib).3Permission is granted to use, modify, and / or redistribute at will.4*/56#include <stdlib.h>78#ifndef REGTEST9#include "_PDCLIB_io.h"1011/* TODO - "except that a function is called after any previously registered12functions that had already been called at the time it was registered.13*/1415/* TODO: 32 is guaranteed. This should be dynamic but ATM gives problems16with my malloc.17*/18#define NUMBER_OF_SLOTS 401920void (*_PDCLIB_exitstack[ NUMBER_OF_SLOTS ])( void ) = { _PDCLIB_closeall };21size_t _PDCLIB_exitptr = NUMBER_OF_SLOTS;2223void exit( int status )24{25while ( _PDCLIB_exitptr < NUMBER_OF_SLOTS )26{27_PDCLIB_exitstack[ _PDCLIB_exitptr++ ]();28}29_Exit( status );30}3132#endif3334#ifdef TEST35#include "_PDCLIB_test.h"3637int main( void )38{39/* Unwinding of regstack tested in atexit(). */40return TEST_RESULTS;41}4243#endif444546