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