|
@@ -12,45 +12,17 @@
|
|
* Combined atexit and __do_exit into one object file.
|
|
* Combined atexit and __do_exit into one object file.
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <errno.h>
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- * NOTE!!! The following should match the value returned by
|
|
|
|
- * by sysconf(_SC_ATEXIT_MAX) in unistd/sysconf.c
|
|
|
|
- */
|
|
|
|
-#define MAXATEXIT 20
|
|
|
|
-
|
|
|
|
typedef void (*vfuncp) (void);
|
|
typedef void (*vfuncp) (void);
|
|
-
|
|
|
|
extern vfuncp __cleanup;
|
|
extern vfuncp __cleanup;
|
|
-extern void __do_exit();
|
|
|
|
-extern void _exit __P((int __status)) __attribute__ ((__noreturn__));
|
|
|
|
-
|
|
|
|
-extern vfuncp __atexit_table[MAXATEXIT];
|
|
|
|
-extern int __atexit_count;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
#ifdef L_atexit
|
|
#ifdef L_atexit
|
|
-int atexit(vfuncp ptr)
|
|
+static vfuncp __atexit_table[__UCLIBC_MAX_ATEXIT];
|
|
-{
|
|
+static int __atexit_count = 0;
|
|
- if ((__atexit_count < 0) || (__atexit_count >= MAXATEXIT)) {
|
|
|
|
- errno = ENOMEM;
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- if (ptr) {
|
|
|
|
- __cleanup = __do_exit;
|
|
|
|
- __atexit_table[__atexit_count++] = ptr;
|
|
|
|
- }
|
|
|
|
- return 0;
|
|
|
|
-}
|
|
|
|
|
|
|
|
-vfuncp __atexit_table[MAXATEXIT];
|
|
+static void __do_exit(void)
|
|
-int __atexit_count = 0;
|
|
|
|
-
|
|
|
|
-void __do_exit(int rv)
|
|
|
|
{
|
|
{
|
|
int count = __atexit_count - 1;
|
|
int count = __atexit_count - 1;
|
|
|
|
|
|
@@ -62,6 +34,19 @@ void __do_exit(int rv)
|
|
(*__atexit_table[count])();
|
|
(*__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
|
|
#endif
|
|
|
|
|
|
#ifdef L_exit
|
|
#ifdef L_exit
|