summaryrefslogtreecommitdiff
path: root/src/stdlib/exit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/exit.c')
-rw-r--r--src/stdlib/exit.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/stdlib/exit.c b/src/stdlib/exit.c
index 55800ace..60a933b8 100644
--- a/src/stdlib/exit.c
+++ b/src/stdlib/exit.c
@@ -1,5 +1,3 @@
-#if 0
-
#include <stdlib.h>
#include <stdio.h>
#include "_stdlib.h"
@@ -11,6 +9,14 @@ _Noreturn void exit(int status)
long scno = __syscall_lookup(exit);
struct atexit *ae = &(__stdlib.atexit);
+ if (__stdlib.quick_exit_called) {
+ __stdlib.constraint_handler("Undefined behavior: exit() called after quick_exit()", NULL, 0);
+ }
+ if (__stdlib.exit_called) {
+ __stdlib.constraint_handler("Undefined behavior: exit() called twice", NULL, 0);
+ }
+ __stdlib.exit_called = 1;
+
/* execute all atexit() registered functions in reverse order */
while (ae) {
int i = ae->nfns;
@@ -47,6 +53,3 @@ IMPLEMENTATION(The unsuccessful termination value returned to the host environme
/*
STDC(1)
*/
-
-
-#endif