From 8a0efa53e44919bcf5ccb1d3353618a82afdf8bc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 17 Feb 2000 19:39:52 +0000 Subject: import newlib-2000-02-17 snapshot --- newlib/libc/stdlib/exit.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 newlib/libc/stdlib/exit.c (limited to 'newlib/libc/stdlib/exit.c') diff --git a/newlib/libc/stdlib/exit.c b/newlib/libc/stdlib/exit.c new file mode 100644 index 0000000..543bd0e --- /dev/null +++ b/newlib/libc/stdlib/exit.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * %sccs.include.redist.c% + */ + +/* +FUNCTION +<>---end program execution + +INDEX + exit + +ANSI_SYNOPSIS + #include + void exit(int <[code]>); + +TRAD_SYNOPSIS + #include + void exit(<[code]>) + int <[code]>; + +DESCRIPTION +Use <> to return control from a program to the host operating +environment. Use the argument <[code]> to pass an exit status to the +operating environment: two particular values, <> and +<>, are defined in `<>' to indicate success or +failure in a portable fashion. + +<> does two kinds of cleanup before ending execution of your +program. First, it calls all application-defined cleanup functions +you have enrolled with <>. Second, files and streams are +cleaned up: any pending output is delivered to the host system, each +open file or stream is closed, and files created by <> are +deleted. + +RETURNS +<> does not return to its caller. + +PORTABILITY +ANSI C requires <>, and specifies that <> and +<> must be defined. + +Supporting OS subroutines required: <<_exit>>. +*/ + +#include +#include /* for _exit() declaration */ +#include + +#ifndef _REENT_ONLY + +/* + * Exit, flushing stdio buffers if necessary. + */ + +void +_DEFUN (exit, (code), + int code) +{ + register struct _atexit *p; + register int n; + + for (p = _REENT->_atexit; p; p = p->_next) + for (n = p->_ind; --n >= 0;) + (*p->_fns[n]) (); + if (_REENT->__cleanup) + (*_REENT->__cleanup) (_REENT); + _exit (code); +} + +#endif -- cgit v1.1