summaryrefslogtreecommitdiff
path: root/libc/stdlib/atexit.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2000-10-09 20:06:30 +0000
committerEric Andersen <andersen@codepoet.org>2000-10-09 20:06:30 +0000
commitc1fe19d4c1db610692365472a90f4661e48449c1 (patch)
treed0b0219ffca3c4c4256f55c4aea4513e43d6aecd /libc/stdlib/atexit.c
parent9efafb8bbc7408b04643dcd53825d971577b4d9d (diff)
Bug ugly formatting update
Diffstat (limited to 'libc/stdlib/atexit.c')
-rw-r--r--libc/stdlib/atexit.c108
1 files changed, 49 insertions, 59 deletions
diff --git a/libc/stdlib/atexit.c b/libc/stdlib/atexit.c
index 7c6a03af8..1c164ff86 100644
--- a/libc/stdlib/atexit.c
+++ b/libc/stdlib/atexit.c
@@ -14,20 +14,18 @@
#include <errno.h>
/* ATEXIT.H */
-#define MAXONEXIT 20 /* AIUI Posix requires 10 */
+#define MAXONEXIT 20 /* AIUI Posix requires 10 */
typedef void (*vfuncp) ();
extern vfuncp __cleanup;
extern void __do_exit();
-extern void _exit __P ((int __status)) __attribute__ ((__noreturn__));
+extern void _exit __P((int __status)) __attribute__ ((__noreturn__));
-extern struct exit_table
-{
- vfuncp called;
- void *argument;
-}
-__on_exit_table[MAXONEXIT];
+extern struct exit_table {
+ vfuncp called;
+ void *argument;
+} __on_exit_table[MAXONEXIT];
extern int __on_exit_count;
@@ -36,83 +34,75 @@ extern int __on_exit_count;
#ifdef L_atexit
vfuncp __cleanup;
-int
-atexit(ptr)
+int atexit(ptr)
vfuncp ptr;
{
- if( __on_exit_count < 0 || __on_exit_count >= MAXONEXIT)
- {
- errno = ENOMEM;
- return -1;
- }
- __cleanup = __do_exit;
- if( ptr )
- {
- __on_exit_table[__on_exit_count].called = ptr;
- __on_exit_table[__on_exit_count].argument = 0;
- __on_exit_count++;
- }
- return 0;
+ if (__on_exit_count < 0 || __on_exit_count >= MAXONEXIT) {
+ errno = ENOMEM;
+ return -1;
+ }
+ __cleanup = __do_exit;
+ if (ptr) {
+ __on_exit_table[__on_exit_count].called = ptr;
+ __on_exit_table[__on_exit_count].argument = 0;
+ __on_exit_count++;
+ }
+ return 0;
}
#endif
#ifdef L_on_exit
-int
-on_exit(ptr, arg)
+int on_exit(ptr, arg)
vfuncp ptr;
void *arg;
{
- if( __on_exit_count < 0 || __on_exit_count >= MAXONEXIT)
- {
- errno = ENOMEM;
- return -1;
- }
- __cleanup = __do_exit;
- if( ptr )
- {
- __on_exit_table[__on_exit_count].called = ptr;
- __on_exit_table[__on_exit_count].argument = arg;
- __on_exit_count++;
- }
- return 0;
+ if (__on_exit_count < 0 || __on_exit_count >= MAXONEXIT) {
+ errno = ENOMEM;
+ return -1;
+ }
+ __cleanup = __do_exit;
+ if (ptr) {
+ __on_exit_table[__on_exit_count].called = ptr;
+ __on_exit_table[__on_exit_count].argument = arg;
+ __on_exit_count++;
+ }
+ return 0;
}
#endif
#ifdef L___do_exit
-int __on_exit_count = 0;
+int __on_exit_count = 0;
struct exit_table __on_exit_table[MAXONEXIT];
-void
-__do_exit(rv)
-int rv;
+void __do_exit(rv)
+int rv;
{
- register int count = __on_exit_count-1;
- register vfuncp ptr;
- __on_exit_count = -1; /* ensure no more will be added */
- __cleanup = 0; /* Calling exit won't re-do this */
-
- /* In reverse order */
- for (; count >= 0; count--)
- {
- ptr = __on_exit_table[count].called;
- (*ptr) (rv, __on_exit_table[count].argument);
- }
+ register int count = __on_exit_count - 1;
+ register vfuncp ptr;
+
+ __on_exit_count = -1; /* ensure no more will be added */
+ __cleanup = 0; /* Calling exit won't re-do this */
+
+ /* In reverse order */
+ for (; count >= 0; count--) {
+ ptr = __on_exit_table[count].called;
+ (*ptr) (rv, __on_exit_table[count].argument);
+ }
}
#endif
#ifdef L_exit
-void
-exit(rv)
-int rv;
+void exit(rv)
+int rv;
{
- if (__cleanup)
- __cleanup();
- _exit(rv);
+ if (__cleanup)
+ __cleanup();
+ _exit(rv);
}
#endif