aboutsummaryrefslogtreecommitdiffstats
path: root/src/pdclib/functions/stdlib/abort.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdclib/functions/stdlib/abort.c')
-rw-r--r--src/pdclib/functions/stdlib/abort.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/pdclib/functions/stdlib/abort.c b/src/pdclib/functions/stdlib/abort.c
new file mode 100644
index 0000000..69422f9
--- /dev/null
+++ b/src/pdclib/functions/stdlib/abort.c
@@ -0,0 +1,40 @@
+/* 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 <stdlib.h>
+#include <signal.h>
+
+#ifndef REGTEST
+
+void abort( void )
+{
+ raise( SIGABRT );
+ exit( EXIT_FAILURE );
+}
+
+#endif
+
+#ifdef TEST
+
+#include "_PDCLIB_test.h"
+
+#include <stdio.h>
+
+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