| Rev | Line | |
|---|
| [1] | 1 | #include <stdlib.h> |
|---|
| 2 | #include <unistd.h> |
|---|
| 3 | #include <pthread.h> |
|---|
| 4 | #include "dietstdio.h" |
|---|
| 5 | |
|---|
| 6 | typedef void (*function)(void); |
|---|
| 7 | |
|---|
| 8 | #define NUM_ATEXIT 32 |
|---|
| 9 | |
|---|
| 10 | static function __atexitlist[NUM_ATEXIT]; |
|---|
| 11 | static int atexit_counter; |
|---|
| 12 | |
|---|
| 13 | int atexit(function t) { |
|---|
| 14 | if (atexit_counter<NUM_ATEXIT) { |
|---|
| 15 | __atexitlist[atexit_counter]=t; |
|---|
| 16 | ++atexit_counter; |
|---|
| 17 | return 0; |
|---|
| 18 | } |
|---|
| 19 | return -1; |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | void exit(int status) |
|---|
| 24 | { |
|---|
| 25 | register int i=atexit_counter; |
|---|
| 26 | |
|---|
| 27 | //__stdio_flushall(); |
|---|
| 28 | |
|---|
| 29 | while(i) { |
|---|
| 30 | __atexitlist[--i](); |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | pthread_exit((void*) status); |
|---|
| 34 | exit(status); |
|---|
| 35 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.