Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Unified Diff: fusl/src/exit/exit.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/exit/atexit.c ('k') | fusl/src/exit/quick_exit.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/exit/exit.c
diff --git a/fusl/src/exit/exit.c b/fusl/src/exit/exit.c
new file mode 100644
index 0000000000000000000000000000000000000000..bf7835a15cd2d3ecf9d7d7c7e8e1dc25a62d2806
--- /dev/null
+++ b/fusl/src/exit/exit.c
@@ -0,0 +1,34 @@
+#include <stdlib.h>
+#include <stdint.h>
+#include "libc.h"
+
+static void dummy()
+{
+}
+
+/* atexit.c and __stdio_exit.c override these. the latter is linked
+ * as a consequence of linking either __toread.c or __towrite.c. */
+weak_alias(dummy, __funcs_on_exit);
+weak_alias(dummy, __stdio_exit);
+weak_alias(dummy, _fini);
+
+__attribute__((__weak__, __visibility__("hidden")))
+extern void (*const __fini_array_start)(void), (*const __fini_array_end)(void);
+
+static void libc_exit_fini(void)
+{
+ uintptr_t a = (uintptr_t)&__fini_array_end;
+ for (; a>(uintptr_t)&__fini_array_start; a-=sizeof(void(*)()))
+ (*(void (**)())(a-sizeof(void(*)())))();
+ _fini();
+}
+
+weak_alias(libc_exit_fini, __libc_exit_fini);
+
+_Noreturn void exit(int code)
+{
+ __funcs_on_exit();
+ __libc_exit_fini();
+ __stdio_exit();
+ _Exit(code);
+}
« no previous file with comments | « fusl/src/exit/atexit.c ('k') | fusl/src/exit/quick_exit.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698