ack/lang/cem/libcc.ansi/stdlib/exit.c

36 lines
641 B
C
Raw Normal View History

1989-05-16 13:13:53 +00:00
/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Header$ */
1989-12-18 15:14:14 +00:00
#include <stdio.h>
1989-05-16 13:13:53 +00:00
#include <stdlib.h>
#define NEXITS 32
1989-12-18 15:14:14 +00:00
void (*__functab[NEXITS])(void);
int __funccnt = 0;
1989-05-16 13:13:53 +00:00
extern void _exit(int);
1989-12-18 15:14:14 +00:00
/* only fflush when there is output */
int (*_fflush)(FILE *stream) = NULL;
1989-05-16 13:13:53 +00:00
static void
_calls(void)
{
1989-12-18 15:14:14 +00:00
register int i = __funccnt;
1989-05-16 13:13:53 +00:00
/* "Called in reversed order of their registration" */
while (--i >= 0)
1989-12-18 15:14:14 +00:00
(*__functab[i])();
1989-05-16 13:13:53 +00:00
}
void
exit(int status)
{
_calls();
1989-12-18 15:14:14 +00:00
if (_fflush) _fflush((FILE *)NULL) ;
1989-05-16 13:13:53 +00:00
_exit(status) ;
}