blob: b2fde9ca290d2d7696cb4f5bff5d3b227e5a83c2 [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{
Roberto Vargas6c373342018-05-24 13:34:53 +010013 if (exitfun)
14 (*exitfun)();
15 for (;;)
16 ;
17}
18
19int atexit(void (*fun)(void))
20{
21 if (exitfun)
22 return -1;
23 exitfun = fun;
24
25 return 0;
Juan Castilloe509d052014-11-17 17:27:41 +000026}