scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

atexit.c (255B)


      1 #include <stdlib.h>
      2 #include <errno.h>
      3 #undef atexit
      4 
      5 extern void (*_exitf[_ATEXIT_MAX])(void);
      6 extern unsigned _exitn;
      7 
      8 int
      9 atexit(void (*fun)(void))
     10 {
     11 	if (_exitn == _ATEXIT_MAX) {
     12 		errno = ENOMEM;
     13 		return -1;
     14 	}
     15 	_exitf[_exitn++] = fun;
     16 	return 0;
     17 }