"./core/ctype/*.c",
"./core/misc/*.c",
"./sys/malloc/*.c",
- "./signal/*.c",
+ "./sys/exit/*.c",
"./assert/*.c",
"./stdio/*.c",
"./stdlib/*.c",
*/
/* $Id$ */
-#if defined(_POSIX_SOURCE)
+#include <stdlib.h>
#include <sys/types.h>
-#endif
#include <signal.h>
-#include <stdlib.h>
-
-extern void (*_clean)(void);
void abort(void)
{
- if (_clean)
- _clean(); /* flush all output files */
raise(SIGABRT);
}
*/
/* $Id$ */
-#if defined(_POSIX_SOURCE)
+#include <stdlib.h>
#include <sys/types.h>
-#endif
#include <signal.h>
+#if ACKCONF_WANT_EMULATED_RAISE
+
int raise(int sig)
{
if (sig < 0 || sig > _NSIG)
return -1;
return kill(getpid(), sig);
}
+
+#endif
#define ACKCONF_WANT_TERMIOS 0
#endif
+#ifndef ACKCONF_WANT_EMULATED_RAISE
+/* Implement raise() in terms of kill() and getpid(). */
+#define ACKCONF_WANT_EMULATED_RAISE 1
+#endif
+
+#ifndef ACKCONF_WANT_MALLOC
+/* Uses sbrk() to get memory from the system. */
+#define ACKCONF_WANT_MALLOC 1
+#endif
+
#endif
+++ /dev/null
-clean:
- rm -f raise.o OLIST
return EOF;
}
-void __cleanup(void)
+static void cleanup(void)
{
register int i;
if (__iotab[i] && io_testflag(__iotab[i], _IOWRITING))
(void)fflush(__iotab[i]);
}
+
+void __register_stdio_cleanup(void)
+{
+ static char registered = 0;
+ if (!registered)
+ {
+ registered = 1;
+ atexit(cleanup);
+ }
+}
#include <unistd.h>
#include "loc_incl.h"
-extern void (*_clean)(void);
-
static int
do_write(int d, char* buf, int nbytes)
{
int __flushbuf(int c, FILE* stream)
{
- _clean = __cleanup;
+ __register_stdio_cleanup();
if (fileno(stream) < 0)
return EOF;
if (!io_testflag(stream, _IOWRITE))
int _doscan(FILE * stream, const char *format, va_list ap);
char *_i_compute(unsigned long val, int base, char *s, int nrdigits);
char *_f_print(va_list *ap, int flags, char *s, char c, int precision);
-void __cleanup(void);
+
+extern void __register_stdio_cleanup(void);
FILE *popen(const char *command, const char *type);
FILE *fdopen(int fd, const char *mode);
{
int retval = 0;
- _clean = __cleanup;
+ __register_stdio_cleanup();
if (mode != _IOFBF && mode != _IOLBF && mode != _IONBF)
return EOF;
/* $Id$ */
#include <stdlib.h>
-
-#define NEXITS 32
-
-extern void (*__functab[NEXITS])(void);
-extern int __funccnt;
+#include "atexits.h"
int atexit(void (*func)(void))
{
--- /dev/null
+#ifndef ATEXITS_H
+#define ATEXITS_H
+
+#define NEXITS 32
+
+extern void (*__functab[NEXITS])(void);
+extern int __funccnt;
+
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
-
-#define NEXITS 32
+#include "atexits.h"
void (*__functab[NEXITS])(void);
int __funccnt = 0;
-/* only flush output buffers when necessary */
-int (*_clean)(void) = NULL;
-
-static void
-_calls(void)
+void exit(int status)
{
- register int i = __funccnt;
-
/* "Called in reversed order of their registration" */
- while (--i >= 0)
- (*__functab[i])();
-}
+ while (__funccnt >= 0)
+ (*__functab[__funccnt])();
-void exit(int status)
-{
- _calls();
- if (_clean)
- _clean();
_exit(status);
}