PatchworkOS
966e257
A non-POSIX operating system.
Theme:
Default
Round
Robot
Loading...
Searching...
No Matches
exit_stack.c
Go to the documentation of this file.
1
#include "
exit_stack.h
"
2
3
#include <
errno.h
>
4
#include <
stdint.h
>
5
6
static
void (*
_stack
[
_EXIT_STACK_SIZE
])(void);
7
static
uint64_t
_length
= 0;
8
9
void
_exit_stack_init
(
void
)
10
{
11
_length
= 0;
12
}
13
14
uint64_t
_exit_stack_push
(
void
(*func)(
void
))
15
{
16
if
(
_length
==
_EXIT_STACK_SIZE
)
17
{
18
return
ERR
;
19
}
20
else
21
{
22
_stack
[
_length
++] = func;
23
return
0;
24
}
25
}
26
27
void
_exit_stack_dispatch
(
void
)
28
{
29
while
(
_length
!= 0)
30
{
31
_stack
[--
_length
]();
32
}
33
}
errno.h
_stack
static void(* _stack[_EXIT_STACK_SIZE])(void)
Definition
exit_stack.c:6
_length
static uint64_t _length
Definition
exit_stack.c:7
_exit_stack_dispatch
void _exit_stack_dispatch(void)
Definition
exit_stack.c:27
_exit_stack_push
uint64_t _exit_stack_push(void(*func)(void))
Definition
exit_stack.c:14
_exit_stack_init
void _exit_stack_init(void)
Definition
exit_stack.c:9
exit_stack.h
_EXIT_STACK_SIZE
#define _EXIT_STACK_SIZE
Definition
exit_stack.h:5
ERR
#define ERR
Integer error value.
Definition
ERR.h:17
stdint.h
uint64_t
__UINT64_TYPE__ uint64_t
Definition
stdint.h:17
src
libstd
user
common
exit_stack.c
Generated on Mon Dec 15 2025 21:55:53 for PatchworkOS by
1.9.8