Skip to content

Instantly share code, notes, and snippets.

View GoodiesHQ's full-sized avatar

Austin GoodiesHQ

View GitHub Profile
@m1lkweed
m1lkweed / xsetjmp.c
Last active September 16, 2024 23:01
Assembly-free setjmp in C. Compile with `-znoexecstack` on any optimization level
#pragma once
// (c) M1lkweed, 2022-2023
// Released as GPLv3+
// Differences from normal setjmp:
// 1.) volatile is not required to prevent clobbering
// 2.) sizeof(xjmp_buf) is 8
// 3.) xlongjmp can be used more than once per buffer
// 4.) reading the return value of xsetjmp is not UB
// 5.) all of the points also apply to the sig*jmp family