blob: f4ffe27cfb6a96447d92a7cf176151bfce2de794 [file] [log] [blame]
Juan Castillo9e751572014-11-17 17:27:41 +00001/*
Roberto Vargas05712702018-02-12 12:36:17 +00002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Juan Castillo9e751572014-11-17 17:27:41 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Juan Castillo9e751572014-11-17 17:27:41 +00005 */
6
Roberto Vargas05712702018-02-12 12:36:17 +00007#include <stdlib.h>
Juan Castillo9e751572014-11-17 17:27:41 +00008
Roberto Vargas64d4de02018-05-24 13:34:53 +01009static void (*exitfun)(void);
10
11void exit(int status)
12{
Antonio Nino Diaz2e74f9b2018-08-23 15:11:46 +010013 if (exitfun != NULL)
Roberto Vargas64d4de02018-05-24 13:34:53 +010014 (*exitfun)();
15 for (;;)
16 ;
17}
18
19int atexit(void (*fun)(void))
Juan Castillo9e751572014-11-17 17:27:41 +000020{
Antonio Nino Diaz2e74f9b2018-08-23 15:11:46 +010021 if (exitfun != NULL)
Roberto Vargas64d4de02018-05-24 13:34:53 +010022 return -1;
23 exitfun = fun;
24
25 return 0;
Juan Castillo9e751572014-11-17 17:27:41 +000026}