1#ifndef	_SETJMP_H
 2#define	_SETJMP_H
 3
 4#ifdef __cplusplus
 5extern "C" {
 6#endif
 7
 8#include <features.h>
 9
10#ifndef __wasilibc_unmodified_upstream
11/* WASI has no setjmp */
12#if !defined(__wasm_exception_handling__)
13#error Setjmp/longjmp support requires Exception handling support, which is [not yet standardized](https://github.com/WebAssembly/proposals?tab=readme-ov-file#phase-3---implementation-phase-cg--wg). To enable it, compile with `-mllvm -wasm-enable-sjlj` and use an engine that implements the Exception handling proposal.
14#endif
15#endif
16#include <bits/setjmp.h>
17
18typedef struct __jmp_buf_tag {
19	__jmp_buf __jb;
20	unsigned long __fl;
21	unsigned long __ss[128/sizeof(long)];
22} jmp_buf[1];
23
24#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
25#define __setjmp_attr __attribute__((__returns_twice__))
26#else
27#define __setjmp_attr
28#endif
29
30#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
31 || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
32 || defined(_BSD_SOURCE)
33typedef jmp_buf sigjmp_buf;
34int sigsetjmp (sigjmp_buf, int) __setjmp_attr;
35_Noreturn void siglongjmp (sigjmp_buf, int);
36#endif
37
38#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
39 || defined(_BSD_SOURCE)
40int _setjmp (jmp_buf) __setjmp_attr;
41_Noreturn void _longjmp (jmp_buf, int);
42#endif
43
44int setjmp (jmp_buf) __setjmp_attr;
45_Noreturn void longjmp (jmp_buf, int);
46
47#define setjmp setjmp
48
49#undef __setjmp_attr
50
51#ifdef __cplusplus
52}
53#endif
54
55#endif