source: azure_iot_hub/trunk/musl-1.1.18/src/exit/at_quick_exit.c@ 389

Last change on this file since 389 was 389, checked in by coas-nagasima, 5 years ago

ビルドが通るよう更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 431 bytes
RevLine 
[388]1#include <stdlib.h>
2#include "libc.h"
3
4#define COUNT 32
5
6static void (*funcs[COUNT])(void);
7static int count;
8static volatile int lock[2];
9
10void __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
22int 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.