mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-16 03:19:54 +08:00
e2ac49d3d7
Lite exit support. * README: Add information about lite-exit. * acconfig.h (_LITE_EXIT): New macro. * configure.in (enable-lite-exit): New option. (_LITE_EXIT): Define new macro. * configure: Regenerated. * newlib.hin (_LITE_EXIT): New macro. * libc/stdlib/__atexit.c [_LITE_EXIT]: Add dummy explicit reference to __call_exitprocs. * libc/stdlib/cxa_atexit.c [_LITE_EXIT]: Make __register_exitproc a weak reference. * libc/stdlib/exit.c (exit)[_LITE_EXIT]: Remove TWS and weakly reference __call_exitprocs.
72 lines
1.7 KiB
C
72 lines
1.7 KiB
C
/*
|
|
* Copyright (c) 1990 Regents of the University of California.
|
|
* All rights reserved.
|
|
*
|
|
* %sccs.include.redist.c%
|
|
*/
|
|
|
|
/*
|
|
FUNCTION
|
|
<<exit>>---end program execution
|
|
|
|
INDEX
|
|
exit
|
|
|
|
ANSI_SYNOPSIS
|
|
#include <stdlib.h>
|
|
void exit(int <[code]>);
|
|
|
|
TRAD_SYNOPSIS
|
|
#include <stdlib.h>
|
|
void exit(<[code]>)
|
|
int <[code]>;
|
|
|
|
DESCRIPTION
|
|
Use <<exit>> 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, <<EXIT_SUCCESS>> and
|
|
<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success or
|
|
failure in a portable fashion.
|
|
|
|
<<exit>> does two kinds of cleanup before ending execution of your
|
|
program. First, it calls all application-defined cleanup functions
|
|
you have enrolled with <<atexit>>. 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 <<tmpfile>> are
|
|
deleted.
|
|
|
|
RETURNS
|
|
<<exit>> does not return to its caller.
|
|
|
|
PORTABILITY
|
|
ANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and
|
|
<<EXIT_FAILURE>> must be defined.
|
|
|
|
Supporting OS subroutines required: <<_exit>>.
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <unistd.h> /* for _exit() declaration */
|
|
#include <reent.h>
|
|
#include "atexit.h"
|
|
|
|
/*
|
|
* Exit, flushing stdio buffers if necessary.
|
|
*/
|
|
|
|
void
|
|
_DEFUN (exit, (code),
|
|
int code)
|
|
{
|
|
#ifdef _LITE_EXIT
|
|
/* Refer to comments in __atexit.c for more details of lite exit. */
|
|
void __call_exitprocs _PARAMS ((int, _PTR)) __attribute__((weak));
|
|
if (__call_exitprocs)
|
|
#endif
|
|
__call_exitprocs (code, NULL);
|
|
|
|
if (_GLOBAL_REENT->__cleanup)
|
|
(*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT);
|
|
_exit (code);
|
|
}
|