SETJMP(9)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’… SETJMP(9) πŸ’…

okay so bestie, welcome to the Kernel Developer's Manual, section 9 β€” this is the setjmp / longjmp page and it is literally about non-local jumps. yes. jumps that are not local. we're going places we shouldn't be able to go and honestly? iconic. ✨


πŸŽ€ NAME πŸŽ€

setjmp, longjmp β€” non-local jumps πŸ¦‹


✨ SYNOPSIS ✨

#include <machine/types.h>
#include <sys/systm.h>

int
setjmp(label_t *label);

void
longjmp(label_t *label);

like, that's the whole vibe check right there. two functions. one label pointer each. no cap. πŸ’…


πŸ’– DESCRIPTION πŸ’–

okay so the way this works is: setjmp() saves its calling environment in label. that's it, that's the whole job. and it returns zero on success β€” so if you see a 0 come back, that's a slay, everything worked. 🫢

then there's longjmp(), which is the main character of this whole operation. it restores the environment that was saved by the most recent invocation of setjmp(). and then β€” and this is the part that's giving time-travel β€” it returns so that kernel execution continues as if the corresponding invocation of the setjmp() had just returned. 😭✨ like you just teleported backwards and nobody around you can even tell. obsessed.

ngl, the lore here is that setjmp() and longjmp() are a machine-independent interface for machine-dependent implementations. so like, the vibe is portable, the guts are not. iykyk. 🧚

and who's actually using these? these functions are primarily used by ddb(4). that's the one. the debugger bestie. πŸ’€


🌈 SEE ALSO 🌈


that's the whole page, bestie β€” go forth and jump non-locally πŸ‘‘

signed, sealed, delivered with love from Debian, dated May 23, 2002 β€” yeah she's vintage, she's a classic, and she still ate πŸ’œπŸŽ€

πŸ“¦ where this page comes from