xref: /rk3399_ARM-atf/lib/libc/exit.c (revision 72e8f2456af54b75a0a1d92aadfce0b4bcde6ba1)
161f72a34SRoberto Vargas /*
2*4c700c15SGovindraj Raja  * Copyright (c) 2015-2018, Arm Limited and Contributors. All rights reserved.
361f72a34SRoberto Vargas  *
461f72a34SRoberto Vargas  * SPDX-License-Identifier: BSD-3-Clause
561f72a34SRoberto Vargas  */
661f72a34SRoberto Vargas 
761f72a34SRoberto Vargas #include <stdlib.h>
861f72a34SRoberto Vargas 
96c373345SRoberto Vargas static void (*exitfun)(void);
106c373345SRoberto Vargas 
exit(int status)116c373345SRoberto Vargas void exit(int status)
1261f72a34SRoberto Vargas {
13d5ccb754SAntonio Nino Diaz 	if (exitfun != NULL)
146c373345SRoberto Vargas 		(*exitfun)();
156c373345SRoberto Vargas 	for (;;)
166c373345SRoberto Vargas 		;
176c373345SRoberto Vargas }
186c373345SRoberto Vargas 
atexit(void (* fun)(void))196c373345SRoberto Vargas int atexit(void (*fun)(void))
206c373345SRoberto Vargas {
21d5ccb754SAntonio Nino Diaz 	if (exitfun != NULL)
226c373345SRoberto Vargas 		return -1;
236c373345SRoberto Vargas 	exitfun = fun;
246c373345SRoberto Vargas 
256c373345SRoberto Vargas 	return 0;
2661f72a34SRoberto Vargas }
27