summaryrefslogtreecommitdiff
path: root/include/setjmp.h
blob: 37d3a8af85dd270c3f85148b1b9fe86b566bfa42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: GPL-2.0-or-later */

#ifndef _SETJMP_H_
#define _SETJMP_H_ 1

#ifdef CONFIG_HAVE_SETJMP
#include <asm/setjmp.h>
#else
struct jmp_buf_data {
};
#endif

/**
 * typedef jmp_buf - information needed to restore a calling environment
 */
typedef struct jmp_buf_data jmp_buf[1];

/**
 * setjmp() - prepare for a long jump
 *
 * Registers, the stack pointer, and the return address are saved in the
 * jump bufffer. The function returns zero afterwards. When longjmp() is
 * executed the function returns a second time with a non-zero value.
 *
 * @env:	jump buffer used to store register values
 * Return:	0 after setting up jump buffer, non-zero after longjmp()
 */
int setjmp(jmp_buf env);

/**
 * longjmp() - long jump
 *
 * Jump back to the address and the register state saved by setjmp().
 *
 * @env:	jump buffer
 * @val:	value to be returned by setjmp(), 0 is replaced by 1
 */
void longjmp(jmp_buf env, int val);

#endif /* _SETJMP_H_ */