13# include <libucontext/libucontext.h>
42# if defined(__FreeBSD__)
43 return (uintptr_t)((
struct sigcontext *)context)->sc_eip;
44# elif defined(__linux__)
46 return (uintptr_t)((ucontext_t *)context)->uc_mcontext.arm_pc;
47# elif defined(__x86_64__)
48 return (uintptr_t)((ucontext_t *)context)->uc_mcontext.gregs[REG_RIP];
49# elif defined(__i386__)
50 return (uintptr_t)((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP];
52# error "Unsupported Linux architecture"
55# error "Operating system unsupported"
65# if defined(__FreeBSD__)
66 ((
struct sigcontext *)context)->sc_eip = (
unsigned int)func;
67# elif defined(__linux__)
69 ((ucontext_t *)context)->uc_mcontext.arm_lr = func;
70 ((ucontext_t *)context)->uc_mcontext.arm_pc = func;
71# elif defined(__x86_64__)
72 ((ucontext_t *)context)->uc_mcontext.gregs[REG_RIP] = (greg_t)func;
73# elif defined(__i386__)
74 ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP] = func;
76# error "Unsupported Linux architecture"
79# error "Operating system unsupported"
89#if defined(__LP64__) || defined(DOXYGEN)
109static inline void makecontext64(ucontext_t *context,
void (*func)(
void),
void* arg) {
110# if defined(__LP64__)
115# if defined(__x86_64__)
116# if defined(__linux__)
117 context->uc_mcontext.gregs[REG_R14] = (greg_t)func;
118 context->uc_mcontext.gregs[REG_R15] = (greg_t)arg;
124 makecontext(context, (
void (*)(
void))func, 1, arg);
void _start_task_func64(void)
Invokes thread task function.
static void _context_set_fptr(ucontext_t *context, uintptr_t func)
Retrieves function pointer generated during calls to makecontext/setcontext/swapcontext
static uintptr_t _context_get_fptr(ucontext_t *context)
Retrieves function pointer generated during calls to makecontext/setcontext/swapcontext
static void makecontext64(ucontext_t *context, void(*func)(void), void *arg)
Like makecontext, allows 64-bit wide function argument on 64-bit platforms.