1897fc685Smortimer #ifndef REGRESS_PIVOT_H
2897fc685Smortimer #define REGRESS_PIVOT_H
3897fc685Smortimer
pivot(void * newstack)4bd23ff4aSkettenis static void pivot(void *newstack) {
5ab1289e9Smortimer #if defined(__aarch64__)
6ab1289e9Smortimer asm("mov sp, %0; ldr lr, [sp]; ret;" ::"r"(newstack));
7ab1289e9Smortimer #elif defined(__amd64__)
86fbf98d6Snaddy asm("mov %0, %%rsp; retq;" ::"r"(newstack));
9897fc685Smortimer #elif defined(__i386__)
106fbf98d6Snaddy asm("mov %0, %%esp; retl;" ::"r"(newstack));
11e0f21b2aSmortimer #elif defined(__mips64__)
12e0f21b2aSmortimer asm("move $sp, %0; ld $ra, 0($sp); jr $ra;" ::"r"(newstack));
134627c47aSmortimer #elif defined(__powerpc64__)
144627c47aSmortimer asm("mr %%r1, %0; ld %%r3, 0(%%r1); mtlr %%r3; blr;" ::"r"(newstack));
154627c47aSmortimer #elif defined(__powerpc__)
164627c47aSmortimer asm("mr %%r1, %0; lwz %%r3, 0(%%r1); mtlr %%r3; blr;" ::"r"(newstack));
17*9206c826Sderaadt #elif defined(__riscv)
18*9206c826Sderaadt asm("mv sp, %0; ld ra, 0(sp); jr ra" ::"r"(newstack));
19897fc685Smortimer #endif
20897fc685Smortimer }
21897fc685Smortimer
22897fc685Smortimer #endif
23