source: trunk/sys/dietlibc/atexit.c @ 111

Last change on this file since 111 was 1, checked in by alain, 8 years ago

First import

File size: 545 bytes
RevLine 
[1]1#include <stdlib.h>
2#include <unistd.h>
3#include <pthread.h>
4#include "dietstdio.h"
5
6typedef void (*function)(void);
7
8#define NUM_ATEXIT      32
9
10static function __atexitlist[NUM_ATEXIT];
11static int atexit_counter;
12
13int 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
23void 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.