X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fabort.c;h=c5adfbd744ee0f21e5f24e2ac60cbc032fab65fb;hb=12e17136786afb1775c9dc946cbe41f5e230c24a;hp=61d3a0139b9b2ccbbc2227e70c3f56d601b74cc6;hpb=dcc8a8e99f69e090a03b7b868443addbc0817820;p=pdclib.old diff --git a/functions/stdlib/abort.c b/functions/stdlib/abort.c index 61d3a01..c5adfbd 100644 --- a/functions/stdlib/abort.c +++ b/functions/stdlib/abort.c @@ -1,8 +1,43 @@ -// ---------------------------------------------------------------------------- -// $Id$ -// ---------------------------------------------------------------------------- -// Public Domain C Library - http://pdclib.sourceforge.net -// This code is Public Domain. Use, modify, and redistribute at will. -// ---------------------------------------------------------------------------- - -void abort( void ) { /* TODO */ }; +/* $Id$ */ + +/* Release $Name$ */ + +/* abort( void ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#include + +#ifndef REGTEST + +void abort( void ) +{ + raise( SIGABRT ); + exit( EXIT_FAILURE ); +} + +#endif + +#ifdef TEST +#include <_PDCLIB_test.h> + +#include + +static void aborthandler( int sig ) +{ + exit( 0 ); +} + +int main( void ) +{ + int UNEXPECTED_RETURN_FROM_ABORT = 0; + TESTCASE( signal( SIGABRT, &aborthandler ) != SIG_ERR ); + abort(); + TESTCASE( UNEXPECTED_RETURN_FROM_ABORT ); + return TEST_RESULTS; +} + +#endif