Annotation of coherent/b/lib/libc/stdlib/atexit.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * libc/stdlib/atexit.c
        !             3:  * C general utilities library.
        !             4:  * atexit()
        !             5:  * ANSI 4.10.4.2.
        !             6:  * Register function for execution on exit.
        !             7:  */
        !             8: 
        !             9: #include <stdlib.h>
        !            10: 
        !            11: #define        ATEXITN 32
        !            12: 
        !            13: /*
        !            14:  * The Standard requires the implementation to support registration
        !            15:  * of at least 32 functions.
        !            16:  * This minimal implementation statically allocates a buffer for 32.
        !            17:  * More could be stored in a malloc'ed buffer, but this code does not do so.
        !            18:  * Globals _atexitn and _atexitfp are defined in exit.c.
        !            19:  */
        !            20: 
        !            21: static void (*atexitfp[ATEXITN])();
        !            22: 
        !            23: int
        !            24: atexit(func) void (*func)();
        !            25: {
        !            26:        if (_atexitn == 0)              /* first time */
        !            27:                _atexitfp = &atexitfp[0];
        !            28:        else if (_atexitn == _ATEXITN)
        !            29:                return 1;               /* too many, failure */
        !            30:        *_atexitfp++ = func;            /* store the function */
        !            31:        ++_atexitn;                     /* and bump the count */
        !            32:        return 0;                       /* success */
        !            33: }
        !            34: 
        !            35: /* end of libc/stdlib/atexit.c */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.