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

Side by Side Diff: fusl/src/exit/at_quick_exit.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 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
OLDNEW
1 #include <stdlib.h> 1 #include <stdlib.h>
2 #include "libc.h" 2 #include "libc.h"
3 3
4 #define COUNT 32 4 #define COUNT 32
5 5
6 static void (*funcs[COUNT])(void); 6 static void (*funcs[COUNT])(void);
7 static int count; 7 static int count;
8 static volatile int lock[2]; 8 static volatile int lock[2];
9 9
10 void __funcs_on_quick_exit() 10 void __funcs_on_quick_exit() {
11 { 11 void (*func)(void);
12 » void (*func)(void); 12 LOCK(lock);
13 » LOCK(lock); 13 while (count > 0) {
14 » while (count > 0) { 14 func = funcs[--count];
15 » » func = funcs[--count]; 15 UNLOCK(lock);
16 » » UNLOCK(lock); 16 func();
17 » » func(); 17 LOCK(lock);
18 » » LOCK(lock); 18 }
19 » }
20 } 19 }
21 20
22 int at_quick_exit(void (*func)(void)) 21 int at_quick_exit(void (*func)(void)) {
23 { 22 if (count == 32)
24 » if (count == 32) return -1; 23 return -1;
25 » LOCK(lock); 24 LOCK(lock);
26 » funcs[count++] = func; 25 funcs[count++] = func;
27 » UNLOCK(lock); 26 UNLOCK(lock);
28 » return 0; 27 return 0;
29 } 28 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698