summaryrefslogtreecommitdiff
path: root/libc/stdlib/atexit.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2001-01-25 21:19:46 +0000
committerManuel Novoa III <mjn3@codepoet.org>2001-01-25 21:19:46 +0000
commitcc07f2350dc260a2a4eaf4ff05f32939c55a9893 (patch)
treeb898aa05768dfd221f31c489d0d01cc2d80be868 /libc/stdlib/atexit.c
parentc4685a5c3c6cef896b3ba7ccb5b628e4489fcb34 (diff)
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.
Diffstat (limited to 'libc/stdlib/atexit.c')
-rw-r--r--libc/stdlib/atexit.c49
1 files changed, 17 insertions, 32 deletions
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 <stdlib.h>
#include <errno.h>
-/* 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