projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
fix indention with spaces in powerpc asm
[oweals/musl.git]
/
src
/
exit
/
at_quick_exit.c
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 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
}