OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [stdlib/] [atexit.c] - Diff between revs 207 and 345

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

Rev 207 Rev 345
/*
/*
 * 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
<<atexit>>---request execution of functions at program exit
<<atexit>>---request execution of functions at program exit
 
 
INDEX
INDEX
        atexit
        atexit
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
        int atexit (void (*<[function]>)(void));
        int atexit (void (*<[function]>)(void));
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
        int atexit ((<[function]>)
        int atexit ((<[function]>)
          void (*<[function]>)();
          void (*<[function]>)();
 
 
DESCRIPTION
DESCRIPTION
You can use <<atexit>> to enroll functions in a list of functions that
You can use <<atexit>> to enroll functions in a list of functions that
will be called when your program terminates normally.  The argument is
will be called when your program terminates normally.  The argument is
a pointer to a user-defined function (which must not require arguments and
a pointer to a user-defined function (which must not require arguments and
must not return a result).
must not return a result).
 
 
The functions are kept in a LIFO stack; that is, the last function
The functions are kept in a LIFO stack; that is, the last function
enrolled by <<atexit>> will be the first to execute when your program
enrolled by <<atexit>> will be the first to execute when your program
exits.
exits.
 
 
There is no built-in limit to the number of functions you can enroll
There is no built-in limit to the number of functions you can enroll
in this list; however, after every group of 32 functions is enrolled,
in this list; however, after every group of 32 functions is enrolled,
<<atexit>> will call <<malloc>> to get space for the next part of the
<<atexit>> will call <<malloc>> to get space for the next part of the
list.   The initial list of 32 functions is statically allocated, so
list.   The initial list of 32 functions is statically allocated, so
you can always count on at least that many slots available.
you can always count on at least that many slots available.
 
 
RETURNS
RETURNS
<<atexit>> returns <<0>> if it succeeds in enrolling your function,
<<atexit>> returns <<0>> if it succeeds in enrolling your function,
<<-1>> if it fails (possible only if no space was available for
<<-1>> if it fails (possible only if no space was available for
<<malloc>> to extend the list of functions).
<<malloc>> to extend the list of functions).
 
 
PORTABILITY
PORTABILITY
<<atexit>> is required by the ANSI standard, which also specifies that
<<atexit>> is required by the ANSI standard, which also specifies that
implementations must support enrolling at least 32 functions.
implementations must support enrolling at least 32 functions.
 
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
*/
 
 
#include <stdlib.h>
#include <stdlib.h>
#include "atexit.h"
#include "atexit.h"
 
 
/*
/*
 * Register a function to be performed at exit.
 * Register a function to be performed at exit.
 */
 */
 
 
int
int
_DEFUN (atexit,
_DEFUN (atexit,
        (fn),
        (fn),
        _VOID _EXFNPTR(fn, (_VOID)))
        _VOID _EXFNPTR(fn, (_VOID)))
{
{
  return __register_exitproc (__et_atexit, fn, NULL, NULL);
  return __register_exitproc (__et_atexit, fn, NULL, NULL);
}
}
 
 

powered by: WebSVN 2.1.0

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