1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LPOSIX/EXIT.C Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,74 @@
1.4 +/* EXIT.C
1.5 + *
1.6 + * Portions Copyright (c) 1990-1999 Nokia Corporation and/or its subsidiary(-ies).
1.7 + * All rights reserved.
1.8 + */
1.9 +
1.10 +/*
1.11 + * Copyright (c) 1990 Regents of the University of California.
1.12 + * All rights reserved.
1.13 + *
1.14 + * %sccs.include.redist.c%
1.15 + */
1.16 +
1.17 +/*
1.18 +FUNCTION
1.19 +<<exit>>---end program execution
1.20 +
1.21 +INDEX
1.22 + exit
1.23 +
1.24 +ANSI_SYNOPSIS
1.25 + #include <stdlib.h>
1.26 + void exit(int <[code]>);
1.27 +
1.28 +TRAD_SYNOPSIS
1.29 + #include <stdlib.h>
1.30 + void exit(<[code]>)
1.31 + int <[code]>;
1.32 +
1.33 +DESCRIPTION
1.34 +Use <<exit>> to return control from a program to the host operating
1.35 +environment. Use the argument <[code]> to pass an exit status to the
1.36 +operating environment: two particular values, <<EXIT_SUCCESS>> and
1.37 +<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success or
1.38 +failure in a portable fashion.
1.39 +
1.40 +<<exit>> does two kinds of cleanup before ending execution of your
1.41 +program. First, it calls all application-defined cleanup functions
1.42 +you have enrolled with <<atexit>>. Second, files and streams are
1.43 +cleaned up: any pending output is delivered to the host system, each
1.44 +open file or stream is closed, and files created by <<tmpfile>> are
1.45 +deleted.
1.46 +
1.47 +RETURNS
1.48 +<<exit>> does not return to its caller.
1.49 +
1.50 +PORTABILITY
1.51 +ANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and
1.52 +<<EXIT_FAILURE>> must be defined.
1.53 +
1.54 +Supporting OS subroutines required: <<_exit>>.
1.55 +*/
1.56 +
1.57 +#include <stdlib.h>
1.58 +#include <unistd.h> /* for _exit() declaration */
1.59 +#include <reent.h>
1.60 +#include <stdlib_r.h> /* for _atexit_processing() */
1.61 +
1.62 +#ifndef _REENT_ONLY
1.63 +
1.64 +/* GCC knows that exit() should not return, but prior to GCC 2.5 there is
1.65 + * no way of declaring the function as __attribute__ ((noreturn)).
1.66 + * Expect to be warned about this function in MARM builds.
1.67 + */
1.68 +EXPORT_C void
1.69 +exit (int code) _ATTRIBUTE((noreturn))
1.70 +{
1.71 + _atexit_processing_r(_REENT);
1.72 + _exit (code);
1.73 +
1.74 + /* GCC may insert a call to abort() here. */
1.75 +}
1.76 +
1.77 +#endif