Path: blob/master/waterbox/libc/functions/stdlib/quick_exit.c
2 views
/* quick_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_quickexitstack[ NUMBER_OF_SLOTS ])( void ) = { 0 };21size_t _PDCLIB_quickexitptr = NUMBER_OF_SLOTS;2223void quick_exit( int status )24{25while ( _PDCLIB_quickexitptr < NUMBER_OF_SLOTS )26{27_PDCLIB_quickexitstack[ _PDCLIB_quickexitptr++ ]();28}29_Exit( status );30}3132#endif3334#ifdef TEST35#include "_PDCLIB_test.h"3637int main( void )38{39/* Unwinding of regstack tested in at_quick_exit(). */40return TEST_RESULTS;41}4243#endif444546