File:  [DVB] / dietlibc / lib / atexit.c
Revision 1.14: download - view: text, annotated - select for diffs
Tue Mar 15 08:51:22 2005 UTC (19 years, 3 months ago) by leitner
Branches: MAIN
CVS tags: HEAD
  Lots of fixes and patches from Markus Oberhumer.
    libstdc++ compatibility
    ilp64 compatibility
    make diet libc compile with -Werror on 13 platforms
  ppc64 now compiles again

#include <stdlib.h>
#include <unistd.h>

typedef void (*function)(void);

#define NUM_ATEXIT	32

static function __atexitlist[NUM_ATEXIT];
static int atexit_counter;

int atexit(function t) {
  if (atexit_counter<NUM_ATEXIT) {
    __atexitlist[atexit_counter]=t;
    ++atexit_counter;
    return 0;
  }
  return -1;
}

extern void __thread_doexit(int doexit);

void __libc_exit(int code);
void __libc_exit(int code) {
  register int i=atexit_counter;
  __thread_doexit(code);
  while(i) {
    __atexitlist[--i]();
  }
  _exit(code);
}
void exit(int code) __attribute__((alias("__libc_exit")));

LinuxTV legacy CVS <linuxtv.org/cvs>