Last change
on this file since 403 was 337, checked in by coas-nagasima, 6 years ago |
ASP3版ECNLを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
431 bytes
|
Line | |
---|
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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.