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