Falexom

Untitled

Jul 20th, 2024
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include "context.h"
  2. #include <setjmp.h>
  3.  
  4. static jmp_buf buf;
  5. static int context_saved = 0;
  6.  
  7. void save_context() {
  8.     if (context_saved == 0) {
  9.         context_saved = setjmp(buf);
  10.     }
  11. }
  12.  
  13. void restore_context() {
  14.     if (context_saved != 0) {
  15.         longjmp(buf, 1);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment