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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « fusl/src/exit/assert.c ('k') | fusl/src/exit/atexit.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <stdlib.h>
2 #include "libc.h"
3
4 #define COUNT 32
5
6 static void (*funcs[COUNT])(void);
7 static int count;
8 static volatile int lock[2];
9
10 void __funcs_on_quick_exit()
11 {
12 void (*func)(void);
13 LOCK(lock);
14 while (count > 0) {
15 func = funcs[--count];
16 UNLOCK(lock);
17 func();
18 LOCK(lock);
19 }
20 }
21
22 int at_quick_exit(void (*func)(void))
23 {
24 if (count == 32) return -1;
25 LOCK(lock);
26 funcs[count++] = func;
27 UNLOCK(lock);
28 return 0;
29 }
OLDNEW
« 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