xref: /rk3399_ARM-atf/lib/libc/exit.c (revision f1f04d786795a02f81abeef7d1513e93098591ed)
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 
11 void exit(int status)
12 {
13 	if (exitfun != NULL)
14 		(*exitfun)();
15 	for (;;)
16 		;
17 }
18 
19 int atexit(void (*fun)(void))
20 {
21 	if (exitfun != NULL)
22 		return -1;
23 	exitfun = fun;
24 
25 	return 0;
26 }
27