10 # include <libucontext/libucontext.h>
12 # include <ucontext.h>
39 # if defined(__FreeBSD__)
40 return (uintptr_t)((
struct sigcontext *)context)->sc_eip;
41 # elif defined(__linux__)
43 return (uintptr_t)((ucontext_t *)context)->uc_mcontext.arm_pc;
44 # elif defined(__x86_64__)
45 return (uintptr_t)((ucontext_t *)context)->uc_mcontext.gregs[REG_RIP];
46 # elif defined(__i386__)
47 return (uintptr_t)((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP];
49 # error "Unsupported Linux architecture"
52 # error "Operating system unsupported"
62 # if defined(__FreeBSD__)
63 ((
struct sigcontext *)context)->sc_eip = (
unsigned int)func;
64 # elif defined(__linux__)
66 ((ucontext_t *)context)->uc_mcontext.arm_lr = func;
67 ((ucontext_t *)context)->uc_mcontext.arm_pc = func;
68 # elif defined(__x86_64__)
69 ((ucontext_t *)context)->uc_mcontext.gregs[REG_RIP] = (greg_t)func;
70 # elif defined(__i386__)
71 ((ucontext_t *)context)->uc_mcontext.gregs[REG_EIP] = func;
73 # error "Unsupported Linux architecture"
76 # error "Operating system unsupported"
86 #if defined(__LP64__) || defined(DOXYGEN)
106 static inline void makecontext64(ucontext_t *context,
void (*func)(
void),
void* arg) {
107 # if defined(__LP64__)
112 # if defined(__x86_64__)
113 # if defined(__linux__)
114 context->uc_mcontext.gregs[REG_R14] = (greg_t)func;
115 context->uc_mcontext.gregs[REG_R15] = (greg_t)arg;
121 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.