source: trunk/libs/newlib/src/newlib/libc/stdlib/exit.c @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.6 KB
Line 
1/*
2 * Copyright (c) 1990 Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.redist.c%
6 */
7
8/*
9FUNCTION
10<<exit>>---end program execution
11
12INDEX
13        exit
14
15SYNOPSIS
16        #include <stdlib.h>
17        void exit(int <[code]>);
18
19DESCRIPTION
20Use <<exit>> to return control from a program to the host operating
21environment.  Use the argument <[code]> to pass an exit status to the
22operating environment: two particular values, <<EXIT_SUCCESS>> and
23<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success or
24failure in a portable fashion.
25
26<<exit>> does two kinds of cleanup before ending execution of your
27program.  First, it calls all application-defined cleanup functions
28you have enrolled with <<atexit>>.  Second, files and streams are
29cleaned up: any pending output is delivered to the host system, each
30open file or stream is closed, and files created by <<tmpfile>> are
31deleted.
32
33RETURNS
34<<exit>> does not return to its caller.
35
36PORTABILITY
37ANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and
38<<EXIT_FAILURE>> must be defined.
39
40Supporting OS subroutines required: <<_exit>>.
41*/
42
43#include <stdlib.h>
44#include <unistd.h>     /* for _exit() declaration */
45#include <reent.h>
46#include "atexit.h"
47
48/*
49 * Exit, flushing stdio buffers if necessary.
50 */
51
52void
53exit (int code)
54{
55#ifdef _LITE_EXIT
56  /* Refer to comments in __atexit.c for more details of lite exit.  */
57  void __call_exitprocs (int, void *)) __attribute__((weak);
58  if (__call_exitprocs)
59#endif
60    __call_exitprocs (code, NULL);
61
62  if (_GLOBAL_REENT->__cleanup)
63    (*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT);
64  _exit (code);
65}
Note: See TracBrowser for help on using the repository browser.