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

Unified Diff: fusl/src/exit/at_quick_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/assert.c ('k') | fusl/src/exit/atexit.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/exit/at_quick_exit.c
diff --git a/fusl/src/exit/at_quick_exit.c b/fusl/src/exit/at_quick_exit.c
new file mode 100644
index 0000000000000000000000000000000000000000..34541badad445160b743c6fe77bee0117f04bf49
--- /dev/null
+++ b/fusl/src/exit/at_quick_exit.c
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+#include "libc.h"
+
+#define COUNT 32
+
+static void (*funcs[COUNT])(void);
+static int count;
+static volatile int lock[2];
+
+void __funcs_on_quick_exit()
+{
+ void (*func)(void);
+ LOCK(lock);
+ while (count > 0) {
+ func = funcs[--count];
+ UNLOCK(lock);
+ func();
+ LOCK(lock);
+ }
+}
+
+int at_quick_exit(void (*func)(void))
+{
+ if (count == 32) return -1;
+ LOCK(lock);
+ funcs[count++] = func;
+ UNLOCK(lock);
+ return 0;
+}
« no previous file with comments | « fusl/src/exit/assert.c ('k') | fusl/src/exit/atexit.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698