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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [stdlib/] [exit.c] - Diff between revs 40 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 40 Rev 1765
/*
/*
 * Copyright (c) 1990 Regents of the University of California.
 * Copyright (c) 1990 Regents of the University of California.
 * All rights reserved.
 * All rights reserved.
 *
 *
 * %sccs.include.redist.c%
 * %sccs.include.redist.c%
 */
 */
 
 
/*
/*
FUNCTION
FUNCTION
<<exit>>---end program execution
<<exit>>---end program execution
 
 
INDEX
INDEX
        exit
        exit
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
        void exit(int <[code]>);
        void exit(int <[code]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
        void exit(<[code]>)
        void exit(<[code]>)
        int <[code]>;
        int <[code]>;
 
 
DESCRIPTION
DESCRIPTION
Use <<exit>> to return control from a program to the host operating
Use <<exit>> to return control from a program to the host operating
environment.  Use the argument <[code]> to pass an exit status to the
environment.  Use the argument <[code]> to pass an exit status to the
operating environment: two particular values, <<EXIT_SUCCESS>> and
operating environment: two particular values, <<EXIT_SUCCESS>> and
<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success or
<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success or
failure in a portable fashion.
failure in a portable fashion.
 
 
<<exit>> does two kinds of cleanup before ending execution of your
<<exit>> does two kinds of cleanup before ending execution of your
program.  First, it calls all application-defined cleanup functions
program.  First, it calls all application-defined cleanup functions
you have enrolled with <<atexit>>.  Second, files and streams are
you have enrolled with <<atexit>>.  Second, files and streams are
cleaned up: any pending output is delivered to the host system, each
cleaned up: any pending output is delivered to the host system, each
open file or stream is closed, and files created by <<tmpfile>> are
open file or stream is closed, and files created by <<tmpfile>> are
deleted.
deleted.
 
 
RETURNS
RETURNS
<<exit>> does not return to its caller.
<<exit>> does not return to its caller.
 
 
PORTABILITY
PORTABILITY
ANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and
ANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and
<<EXIT_FAILURE>> must be defined.
<<EXIT_FAILURE>> must be defined.
 
 
Supporting OS subroutines required: <<_exit>>.
Supporting OS subroutines required: <<_exit>>.
*/
*/
 
 
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>     /* for _exit() declaration */
#include <unistd.h>     /* for _exit() declaration */
#include <reent.h>
#include <reent.h>
 
 
#ifndef _REENT_ONLY
#ifndef _REENT_ONLY
 
 
/*
/*
 * Exit, flushing stdio buffers if necessary.
 * Exit, flushing stdio buffers if necessary.
 */
 */
 
 
void
void
_DEFUN (exit, (code),
_DEFUN (exit, (code),
        int code)
        int code)
{
{
  register struct _atexit *p;
  register struct _atexit *p;
  register int n;
  register int n;
 
 
  for (p = _REENT->_atexit; p; p = p->_next)
  for (p = _REENT->_atexit; p; p = p->_next)
    for (n = p->_ind; --n >= 0;)
    for (n = p->_ind; --n >= 0;)
      (*p->_fns[n]) ();
      (*p->_fns[n]) ();
  if (_REENT->__cleanup)
  if (_REENT->__cleanup)
    (*_REENT->__cleanup) (_REENT);
    (*_REENT->__cleanup) (_REENT);
  _exit (code);
  _exit (code);
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

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