fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1extern "C" int cc_plus_one_cxx(int *arg); 2extern "C" int cc_plus_one_cxx_asm(int *arg); 3 4int cc_plus_one_cxx(int *arg) { 5 return *arg + 1; 6} 7 8int cc_plus_one_cxx_asm(int *arg) { 9 int value = 0; 10 11 asm volatile ( " movl (%1), %0\n" 12 " inc %0\n" 13 " jmp 1f\n" 14 " retq\n" // never executed, but a shortcut to determine how 15 // the assembler deals with `ret` instructions 16 "1:\n" 17 : "=r"(value) 18 : "r"(arg) ); 19 20 return value; 21}