65816-llvm-mos/runtime/include/setjmp.h
Scott Duensing 77202fb7f7 Checkpoint.
2026-04-30 22:04:47 -05:00

14 lines
527 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
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));
#endif