OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [stdlib/] [exit.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
/*
2
 * Copyright (c) 1990 Regents of the University of California.
3
 * All rights reserved.
4
 *
5
 * %sccs.include.redist.c%
6
 */
7
 
8
/*
9
FUNCTION
10
<<exit>>---end program execution
11
 
12
INDEX
13
        exit
14
 
15
ANSI_SYNOPSIS
16
        #include <stdlib.h>
17
        void exit(int <[code]>);
18
 
19
TRAD_SYNOPSIS
20
        #include <stdlib.h>
21
        void exit(<[code]>)
22
        int <[code]>;
23
 
24
DESCRIPTION
25
Use <<exit>> to return control from a program to the host operating
26
environment.  Use the argument <[code]> to pass an exit status to the
27
operating environment: two particular values, <<EXIT_SUCCESS>> and
28
<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success or
29
failure in a portable fashion.
30
 
31
<<exit>> does two kinds of cleanup before ending execution of your
32
program.  First, it calls all application-defined cleanup functions
33
you have enrolled with <<atexit>>.  Second, files and streams are
34
cleaned up: any pending output is delivered to the host system, each
35
open file or stream is closed, and files created by <<tmpfile>> are
36
deleted.
37
 
38
RETURNS
39
<<exit>> does not return to its caller.
40
 
41
PORTABILITY
42
ANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and
43
<<EXIT_FAILURE>> must be defined.
44
 
45
Supporting OS subroutines required: <<_exit>>.
46
*/
47
 
48
#include <stdlib.h>
49
#include <unistd.h>     /* for _exit() declaration */
50
#include <reent.h>
51
 
52
#ifndef _REENT_ONLY
53
 
54
/*
55
 * Exit, flushing stdio buffers if necessary.
56
 */
57
 
58
void
59
_DEFUN (exit, (code),
60
        int code)
61
{
62
  register struct _atexit *p;
63
  register int n;
64
 
65
  for (p = _REENT->_atexit; p; p = p->_next)
66
    for (n = p->_ind; --n >= 0;)
67
      (*p->_fns[n]) ();
68
  if (_REENT->__cleanup)
69
    (*_REENT->__cleanup) (_REENT);
70
  _exit (code);
71
}
72
 
73
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.