65816-llvm-mos/runtime/include/setjmp.h
2026-05-30 19:40:29 -05:00

22 lines
596 B
C

// W65816 setjmp/longjmp — saves SP, return address (24-bit), and DP.
// jmp_buf is 8 bytes of opaque storage.
#ifndef _SETJMP_H
#define _SETJMP_H
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned char jmp_buf[8];
// `returns_twice` tells clang that setjmp may "return" a second time
// (via longjmp) — without this the optimizer may treat env as
// uninitialized after the call and constant-fold reads to 0.
int setjmp(jmp_buf env) __attribute__((returns_twice));
void longjmp(jmp_buf env, int val) __attribute__((noreturn));
#ifdef __cplusplus
}
#endif
#endif