github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/test/testsetjump.c (about) 1 #include "stdio.h" 2 #include "setjmp.h" 3 4 jmp_buf buf; 5 6 extern int setjmp(jmp_buf); 7 extern void longjmp(jmp_buf, int); 8 9 10 void ProgramB() 11 { 12 longjmp(buf,1); 13 } 14 15 16 void ProgramA() 17 { 18 ProgramB(); 19 printf("Program A\n"); 20 } 21 22 23 int main(int an, char**av) 24 { 25 long long int bitset= 0x0005; 26 unsigned n= 1; 27 unsigned* bit_number_ptr= &n; 28 29 asm volatile( 30 "\tmovq %[bit_number_ptr], %%rbx\n" 31 "\tbsrq (%%rbx), %[bitset]\n" 32 : 33 :[bit_number_ptr] "p" (bit_number_ptr), 34 [bitset] "r" (bitset) 35 : "%rbx"); 36 37 printf("Num: %016lx, bitnum: %d, bitptr: %016lx\n", 38 bitset, n, bit_number_ptr); 39 40 if(setjmp(buf)==0) { 41 ProgramA(); 42 } 43 else { 44 printf("back at main\n"); 45 } 46 return 0; 47 }