Heinrich Schuchardt | f6782bb | 2025-03-02 15:21:19 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #ifndef _SETJMP_H_ |
| 4 | #define _SETJMP_H_ 1 |
| 5 | |
| 6 | #ifdef CONFIG_HAVE_SETJMP |
| 7 | #include <asm/setjmp.h> |
| 8 | #else |
| 9 | struct jmp_buf_data { |
| 10 | }; |
| 11 | #endif |
| 12 | |
| 13 | /** |
| 14 | * typedef jmp_buf - information needed to restore a calling environment |
| 15 | */ |
| 16 | typedef struct jmp_buf_data jmp_buf[1]; |
| 17 | |
| 18 | /** |
| 19 | * setjmp() - prepare for a long jump |
| 20 | * |
| 21 | * Registers, the stack pointer, and the return address are saved in the |
| 22 | * jump bufffer. The function returns zero afterwards. When longjmp() is |
| 23 | * executed the function returns a second time with a non-zero value. |
| 24 | * |
| 25 | * @env: jump buffer used to store register values |
| 26 | * Return: 0 after setting up jump buffer, non-zero after longjmp() |
| 27 | */ |
| 28 | int setjmp(jmp_buf env); |
| 29 | |
| 30 | /** |
| 31 | * longjmp() - long jump |
| 32 | * |
| 33 | * Jump back to the address and the register state saved by setjmp(). |
| 34 | * |
| 35 | * @env: jump buffer |
| 36 | * @val: value to be returned by setjmp(), 0 is replaced by 1 |
| 37 | */ |
| 38 | void longjmp(jmp_buf env, int val); |
| 39 | |
| 40 | #endif /* _SETJMP_H_ */ |