exit.c 359 B

1234567891011121314151617181920212223242526
  1. /*
  2. * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdlib.h>
  7. static void (*exitfun)(void);
  8. void exit(int status)
  9. {
  10. if (exitfun != NULL)
  11. (*exitfun)();
  12. for (;;)
  13. ;
  14. }
  15. int atexit(void (*fun)(void))
  16. {
  17. if (exitfun != NULL)
  18. return -1;
  19. exitfun = fun;
  20. return 0;
  21. }