diff options
| author | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 10:32:23 +0100 |
|---|---|---|
| committer | Xavi Del Campo <xavi.dcr@tutanota.com> | 2020-01-31 10:32:23 +0100 |
| commit | 7c24e9a9b02b04dcaf9507acb94091ea70a2c02d (patch) | |
| tree | c28d0748652ad4b4222309e46e6cfc82c0906220 /libpsx/src/atexit.c | |
| parent | a2b7b6bb1cc2f4a3258b7b2dbc92399d151f864d (diff) | |
| download | psxsdk-7c24e9a9b02b04dcaf9507acb94091ea70a2c02d.tar.gz | |
Imported pristine psxsdk-20190410 from official repo
Diffstat (limited to 'libpsx/src/atexit.c')
| -rw-r--r-- | libpsx/src/atexit.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libpsx/src/atexit.c b/libpsx/src/atexit.c new file mode 100644 index 0000000..835aae3 --- /dev/null +++ b/libpsx/src/atexit.c @@ -0,0 +1,23 @@ +#include <stdlib.h> + +static void *f_ptr[32]; +static int f_ptr_pos = 0; + +int atexit(void (*function)(void)) +{ + if(f_ptr_pos >= 32) + return -1; + + f_ptr[f_ptr_pos++] = function; + + return 0; +} + +void call_atexit_callbacks(void) +{ + int i; + void (*f)(void); + + for(i = (f_ptr_pos - 1); i >= 0; i--) + (f = f_ptr[i])(); +} |
