exit.c 343 Bytes
Newer Older
1
/*
2
 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
 */

7
#include <stdlib.h>
8

Roberto Vargas's avatar
Roberto Vargas committed
9
10
11
static void (*exitfun)(void);

void exit(int status)
12
{
Roberto Vargas's avatar
Roberto Vargas committed
13
14
15
16
17
18
19
20
21
22
23
24
25
	if (exitfun)
		(*exitfun)();
	for (;;)
		;
}

int atexit(void (*fun)(void))
{
	if (exitfun)
		return -1;
	exitfun = fun;

	return 0;
26
}