From cc07f2350dc260a2a4eaf4ff05f32939c55a9893 Mon Sep 17 00:00:00 2001 From: Manuel Novoa III Date: Thu, 25 Jan 2001 21:19:46 +0000 Subject: Clean up atexit.c; make sure sysconf and atexit agree; link in ref'd libgcc.a objects with shared uClibc; allow disabling long long support. --- libc/stdlib/atexit.c | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) (limited to 'libc/stdlib/atexit.c') diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c index 5079692af..a7ec0fb1f 100644 --- a/libc/stdlib/atexit.c +++ b/libc/stdlib/atexit.c @@ -12,45 +12,17 @@ * Combined atexit and __do_exit into one object file. */ +#include #include -/* ATEXIT.H */ - -/* - * NOTE!!! The following should match the value returned by - * by sysconf(_SC_ATEXIT_MAX) in unistd/sysconf.c - */ -#define MAXATEXIT 20 /* AIUI Posix requires 10 */ - typedef void (*vfuncp) (void); - extern vfuncp __cleanup; -extern void __do_exit(); -extern void _exit __P((int __status)) __attribute__ ((__noreturn__)); - -extern vfuncp __atexit_table[MAXATEXIT]; -extern int __atexit_count; - -/* End ATEXIT.H */ #ifdef L_atexit -int atexit(vfuncp ptr) -{ - if ((__atexit_count < 0) || (__atexit_count >= MAXATEXIT)) { - errno = ENOMEM; - return -1; - } - if (ptr) { - __cleanup = __do_exit; - __atexit_table[__atexit_count++] = ptr; - } - return 0; -} +static vfuncp __atexit_table[__UCLIBC_MAX_ATEXIT]; +static int __atexit_count = 0; -vfuncp __atexit_table[MAXATEXIT]; -int __atexit_count = 0; - -void __do_exit(int rv) +static void __do_exit(void) { int count = __atexit_count - 1; @@ -62,6 +34,19 @@ void __do_exit(int rv) (*__atexit_table[count])(); } } + +int atexit(vfuncp ptr) +{ + if ((__atexit_count < 0) || (__atexit_count >= __UCLIBC_MAX_ATEXIT)) { + errno = ENOMEM; + return -1; + } + if (ptr) { + __cleanup = __do_exit; + __atexit_table[__atexit_count++] = ptr; + } + return 0; +} #endif #ifdef L_exit -- cgit v1.2.3