summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/atexit.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib/atexit.c')
-rw-r--r--lib/libc/stdlib/atexit.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libc/stdlib/atexit.c b/lib/libc/stdlib/atexit.c
new file mode 100644
index 00000000..6c84fd4a
--- /dev/null
+++ b/lib/libc/stdlib/atexit.c
@@ -0,0 +1,16 @@
+#include <stdlib.h>
+
+static void (*__atexit_fvec[32])(void) = { NULL };
+
+int atexit(void (*func)(void))
+{
+ for (int i = 0; i < 32; i++) {
+ if (__atexit_fvec[i] == NULL) {
+ __atexit_fvec[i] = func;
+ __atexit_fvec[i + 1] = NULL;
+ return 0;
+ }
+ }
+
+ return -1;
+}