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