Juan Castillo | 9e75157 | 2014-11-17 17:27:41 +0000 | [diff] [blame] | 1 | /* |
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Juan Castillo | 9e75157 | 2014-11-17 17:27:41 +0000 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Juan Castillo | 9e75157 | 2014-11-17 17:27:41 +0000 | [diff] [blame] | 5 | */ |
6 | |||||
Roberto Vargas | 0571270 | 2018-02-12 12:36:17 +0000 | [diff] [blame] | 7 | #include <stdlib.h> |
Juan Castillo | 9e75157 | 2014-11-17 17:27:41 +0000 | [diff] [blame] | 8 | |
Roberto Vargas | 64d4de0 | 2018-05-24 13:34:53 +0100 | [diff] [blame] | 9 | static void (*exitfun)(void); |
10 | |||||
11 | void exit(int status) | ||||
12 | { | ||||
Antonio Nino Diaz | 2e74f9b | 2018-08-23 15:11:46 +0100 | [diff] [blame] | 13 | if (exitfun != NULL) |
Roberto Vargas | 64d4de0 | 2018-05-24 13:34:53 +0100 | [diff] [blame] | 14 | (*exitfun)(); |
15 | for (;;) | ||||
16 | ; | ||||
17 | } | ||||
18 | |||||
19 | int atexit(void (*fun)(void)) | ||||
Juan Castillo | 9e75157 | 2014-11-17 17:27:41 +0000 | [diff] [blame] | 20 | { |
Antonio Nino Diaz | 2e74f9b | 2018-08-23 15:11:46 +0100 | [diff] [blame] | 21 | if (exitfun != NULL) |
Roberto Vargas | 64d4de0 | 2018-05-24 13:34:53 +0100 | [diff] [blame] | 22 | return -1; |
23 | exitfun = fun; | ||||
24 | |||||
25 | return 0; | ||||
Juan Castillo | 9e75157 | 2014-11-17 17:27:41 +0000 | [diff] [blame] | 26 | } |