summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib/exit.c
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-22 23:27:56 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-22 23:30:32 +0100
commit0f30d227497418c6d3bef7d52244407e30454504 (patch)
tree0e1ac19623d3268380cf74328cdf643648a2f43c /lib/libc/stdlib/exit.c
parent90dad97fc07f049383903a166631e2c257f9b8c1 (diff)
Added c11 threads, fixed some locks and add *_unlocked functions
Diffstat (limited to 'lib/libc/stdlib/exit.c')
-rw-r--r--lib/libc/stdlib/exit.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/lib/libc/stdlib/exit.c b/lib/libc/stdlib/exit.c
index 7fc96f28..80054637 100644
--- a/lib/libc/stdlib/exit.c
+++ b/lib/libc/stdlib/exit.c
@@ -1,65 +1,14 @@
-#include "__stdio.h" // for __FILE
-#include "stddef.h" // for NULL
-
#include <libc.h> // for weak_reference
-#include <stdio.h> // for fflush, stdout, FILE, stderr, stdin
#include <stdlib.h> // for free, exit
#include <unistd.h> // for _exit, close, write, STDERR_FILENO
void (*__dummy_atexit_fvec)(void);
weak_reference(__dummy_atexit_fvec, __atexit_fvec);
-void (*__dummy_stdio_cleanup)(void);
-weak_reference(__dummy_stdio_cleanup, __stdio_cleanup);
-
-static void __fclose(FILE *stream)
-{
- if (stream == NULL) {
- return;
- }
-
- if (__FILE(stream)->buf_len > 0) {
- fflush(stream);
- }
-
- if (__FILE(stream)->fd > STDERR_FILENO) {
- close(__FILE(stream)->fd);
- }
-
- if (__FILE(stream)->buf) {
- free(__FILE(stream)->buf);
- }
-
- if (stream != stdout && stream != stderr && stream != stdin) {
- free(stream);
- }
-}
-
-static void __stdio_cleanup_impl(void)
-{
- write(1, "HELLO\n", 6);
- fflush(stdout);
-
- if (stdout->next != NULL) {
- FILE *cur = stdout->next;
- while (cur) {
- struct __FILE *next = cur->next;
- __fclose(cur);
- cur = next;
- }
- }
-}
-
void exit(int status)
{
void (*fptr)(void);
- /* Only do stdio cleanup if it was referenced (meaning stdio was used)
- */
- if (__stdio_cleanup) {
- __stdio_cleanup_impl();
- }
-
if (__atexit_fvec) {
fptr = __atexit_fvec;
while (fptr) {