From c31decc3d4820256e62be22486a5f88005fa59a3 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 6 Dec 2020 03:44:45 -0600 Subject: [PATCH] build: use internal definitions to replace things pulled in from ucontext.h --- arch/aarch64/makecontext.c | 1 - arch/arm/makecontext.c | 1 - arch/m68k/makecontext.c | 17 ++++++++--------- arch/ppc/makecontext.c | 11 +++++------ arch/ppc64/makecontext.c | 11 +++++------ arch/riscv64/makecontext.c | 19 +++++++++---------- arch/s390x/makecontext.c | 11 +++++------ arch/x86/makecontext.c | 9 ++++----- arch/x86_64/makecontext.c | 21 ++++++++++----------- 9 files changed, 46 insertions(+), 55 deletions(-) diff --git a/arch/aarch64/makecontext.c b/arch/aarch64/makecontext.c index 85af1c1..d2e90f5 100644 --- a/arch/aarch64/makecontext.c +++ b/arch/aarch64/makecontext.c @@ -13,7 +13,6 @@ #define _GNU_SOURCE #include #include -#include #include #include #include diff --git a/arch/arm/makecontext.c b/arch/arm/makecontext.c index 681b2fc..ae09a9a 100644 --- a/arch/arm/makecontext.c +++ b/arch/arm/makecontext.c @@ -13,7 +13,6 @@ #define _GNU_SOURCE #include #include -#include #include #include #include diff --git a/arch/m68k/makecontext.c b/arch/m68k/makecontext.c index db36fe0..2cbc0f7 100644 --- a/arch/m68k/makecontext.c +++ b/arch/m68k/makecontext.c @@ -13,7 +13,6 @@ #define _GNU_SOURCE #include #include -#include #include #include #include @@ -26,34 +25,34 @@ extern void libucontext_trampoline(void); void libucontext_makecontext(libucontext_ucontext_t *ucp, void (*func)(void), int argc, ...) { - greg_t *sp; + libucontext_greg_t *sp; va_list va; int i; /* set up and align the stack. */ - sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + sp = (libucontext_greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); sp -= (argc + 2); - sp = (greg_t *) (((uintptr_t) sp & ~0x3)); + sp = (libucontext_greg_t *) (((uintptr_t) sp & ~0x3)); /* set up the ucontext structure */ - ucp->uc_mcontext.gregs[REG_SP] = (greg_t) sp; + ucp->uc_mcontext.gregs[REG_SP] = (libucontext_greg_t) sp; ucp->uc_mcontext.gregs[REG_A6] = 0; ucp->uc_mcontext.gregs[REG_D7] = argc; - ucp->uc_mcontext.gregs[REG_PC] = (greg_t) func; + ucp->uc_mcontext.gregs[REG_PC] = (libucontext_greg_t) func; /* return address */ - *sp++ = (greg_t) libucontext_trampoline; + *sp++ = (libucontext_greg_t) libucontext_trampoline; va_start(va, argc); /* all arguments overflow into stack */ for (i = 0; i < argc; i++) - *sp++ = va_arg (va, greg_t); + *sp++ = va_arg (va, libucontext_greg_t); va_end(va); /* link pointer */ - *sp++ = (greg_t) ucp->uc_link; + *sp++ = (libucontext_greg_t) ucp->uc_link; } diff --git a/arch/ppc/makecontext.c b/arch/ppc/makecontext.c index d331670..a7434ad 100644 --- a/arch/ppc/makecontext.c +++ b/arch/ppc/makecontext.c @@ -13,7 +13,6 @@ #define _GNU_SOURCE #include -#include #include @@ -26,16 +25,16 @@ extern void libucontext_trampoline(void); void libucontext_makecontext(ucontext_t *ucp, void (*func)(), int argc, ...) { - greg_t *sp; + libucontext_greg_t *sp; va_list va; int i; unsigned int stack_args; stack_args = argc > 8 ? argc - 8 : 0; - sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + sp = (libucontext_greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); sp -= stack_args + 2; - sp = (greg_t *) ((uintptr_t) sp & -16L); + sp = (libucontext_greg_t *) ((uintptr_t) sp & -16L); ucp->uc_mcontext.gregs[REG_NIP] = (uintptr_t) func; ucp->uc_mcontext.gregs[REG_LNK] = (uintptr_t) &libucontext_trampoline; @@ -48,9 +47,9 @@ libucontext_makecontext(ucontext_t *ucp, void (*func)(), int argc, ...) for (i = 0; i < argc; i++) { if (i < 8) - ucp->uc_mcontext.gregs[i + 3] = va_arg (va, greg_t); + ucp->uc_mcontext.gregs[i + 3] = va_arg (va, libucontext_greg_t); else - sp[i-8 + 2] = va_arg (va, greg_t); + sp[i-8 + 2] = va_arg (va, libucontext_greg_t); } va_end(va); diff --git a/arch/ppc64/makecontext.c b/arch/ppc64/makecontext.c index f328efe..a09bc53 100644 --- a/arch/ppc64/makecontext.c +++ b/arch/ppc64/makecontext.c @@ -13,7 +13,6 @@ #define _GNU_SOURCE #include -#include #include @@ -26,16 +25,16 @@ extern void libucontext_trampoline(void); void libucontext_makecontext(ucontext_t *ucp, void (*func)(), int argc, ...) { - greg_t *sp; + libucontext_greg_t *sp; va_list va; int i; unsigned int stack_args; stack_args = argc > 8 ? argc : 0; - sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + sp = (libucontext_greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); sp -= stack_args + 4; - sp = (greg_t *) ((uintptr_t) sp & -16L); + sp = (libucontext_greg_t *) ((uintptr_t) sp & -16L); ucp->uc_mcontext.gp_regs[REG_NIP] = (uintptr_t) func; ucp->uc_mcontext.gp_regs[REG_LNK] = (uintptr_t) &libucontext_trampoline; @@ -49,9 +48,9 @@ libucontext_makecontext(ucontext_t *ucp, void (*func)(), int argc, ...) for (i = 0; i < argc; i++) { if (i < 8) - ucp->uc_mcontext.gp_regs[i + 3] = va_arg (va, greg_t); + ucp->uc_mcontext.gp_regs[i + 3] = va_arg (va, libucontext_greg_t); else - sp[i + 4] = va_arg (va, greg_t); + sp[i + 4] = va_arg (va, libucontext_greg_t); } va_end(va); diff --git a/arch/riscv64/makecontext.c b/arch/riscv64/makecontext.c index e1a2d59..19d09ed 100644 --- a/arch/riscv64/makecontext.c +++ b/arch/riscv64/makecontext.c @@ -13,7 +13,6 @@ #define _GNU_SOURCE #include #include -#include #include #include #include @@ -26,21 +25,21 @@ extern void libucontext_trampoline(void); void libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) { - greg_t *sp, *regp; + libucontext_greg_t *sp, *regp; va_list va; int i; /* set up and align the stack. */ - sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + sp = (libucontext_greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); sp -= argc < 8 ? 0 : argc - 8; - sp = (greg_t *) (((uintptr_t) sp & -16L)); + sp = (libucontext_greg_t *) (((uintptr_t) sp & -16L)); /* set up the ucontext structure */ - ucp->uc_mcontext.__gregs[REG_RA] = (greg_t) libucontext_trampoline; + ucp->uc_mcontext.__gregs[REG_RA] = (libucontext_greg_t) libucontext_trampoline; ucp->uc_mcontext.__gregs[REG_S0] = 0; - ucp->uc_mcontext.__gregs[REG_S1] = (greg_t) func; - ucp->uc_mcontext.__gregs[REG_S2] = (greg_t) ucp->uc_link; - ucp->uc_mcontext.__gregs[REG_SP] = (greg_t) sp; + ucp->uc_mcontext.__gregs[REG_S1] = (libucontext_greg_t) func; + ucp->uc_mcontext.__gregs[REG_S2] = (libucontext_greg_t) ucp->uc_link; + ucp->uc_mcontext.__gregs[REG_SP] = (libucontext_greg_t) sp; ucp->uc_mcontext.__gregs[REG_PC] = 0; va_start(va, argc); @@ -49,11 +48,11 @@ libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) regp = &(ucp->uc_mcontext.__gregs[REG_A0]); for (i = 0; (i < argc && i < 8); i++) - *regp++ = va_arg (va, greg_t); + *regp++ = va_arg (va, libucontext_greg_t); /* remainder overflows into stack */ for (; i < argc; i++) - *sp++ = va_arg (va, greg_t); + *sp++ = va_arg (va, libucontext_greg_t); va_end(va); } diff --git a/arch/s390x/makecontext.c b/arch/s390x/makecontext.c index 6b089e7..046a9cb 100644 --- a/arch/s390x/makecontext.c +++ b/arch/s390x/makecontext.c @@ -13,7 +13,6 @@ #define _GNU_SOURCE #include #include -#include #include #include @@ -28,12 +27,12 @@ extern int libucontext_setcontext(const ucontext_t *ucp); void libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) { - greg_t *sp; + libucontext_greg_t *sp; va_list va; int i; - sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - sp = (greg_t *) (((uintptr_t) sp & -8L)); + sp = (libucontext_greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + sp = (libucontext_greg_t *) (((uintptr_t) sp & -8L)); ucp->uc_mcontext.gregs[7] = (uintptr_t) func; ucp->uc_mcontext.gregs[8] = (uintptr_t) ucp->uc_link; @@ -43,14 +42,14 @@ libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) va_start(va, argc); for (i = 0; i < argc && i < 5; i++) - ucp->uc_mcontext.gregs[i + 2] = va_arg (va, greg_t); + ucp->uc_mcontext.gregs[i + 2] = va_arg (va, libucontext_greg_t); if (argc > 5) { sp -= argc - 5; for (i = 5; i < argc; i++) - sp[i - 5] = va_arg (va, greg_t); + sp[i - 5] = va_arg (va, libucontext_greg_t); } va_end(va); diff --git a/arch/x86/makecontext.c b/arch/x86/makecontext.c index 02c14f6..bad91f1 100644 --- a/arch/x86/makecontext.c +++ b/arch/x86/makecontext.c @@ -14,7 +14,6 @@ #define _GNU_SOURCE #include #include -#include #include #include @@ -25,16 +24,16 @@ extern void libucontext_trampoline(void); void libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) { - greg_t *sp, *argp; + libucontext_greg_t *sp, *argp; va_list va; int i; unsigned int uc_link; uc_link = (argc > 6 ? argc - 6 : 0) + 1; - sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + sp = (libucontext_greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); sp -= uc_link; - sp = (greg_t *) (((uintptr_t) sp & -16L) - 8); + sp = (libucontext_greg_t *) (((uintptr_t) sp & -16L) - 8); ucp->uc_mcontext.gregs[REG_EIP] = (uintptr_t) func; ucp->uc_mcontext.gregs[REG_EBX] = (uintptr_t) argc; @@ -46,7 +45,7 @@ libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) va_start(va, argc); for (i = 0; i < argc; i++) - *argp++ = va_arg (va, greg_t); + *argp++ = va_arg (va, libucontext_greg_t); va_end(va); diff --git a/arch/x86_64/makecontext.c b/arch/x86_64/makecontext.c index c529650..a1e3e2d 100644 --- a/arch/x86_64/makecontext.c +++ b/arch/x86_64/makecontext.c @@ -13,7 +13,6 @@ #define _GNU_SOURCE #include #include -#include #include #include @@ -25,16 +24,16 @@ extern void libucontext_trampoline(void); void libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) { - greg_t *sp; + libucontext_greg_t *sp; va_list va; int i; unsigned int uc_link; uc_link = (argc > 6 ? argc - 6 : 0) + 1; - sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + sp = (libucontext_greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); sp -= uc_link; - sp = (greg_t *) (((uintptr_t) sp & -16L) - 8); + sp = (libucontext_greg_t *) (((uintptr_t) sp & -16L) - 8); ucp->uc_mcontext.gregs[REG_RIP] = (uintptr_t) func; ucp->uc_mcontext.gregs[REG_RBX] = (uintptr_t) &sp[uc_link]; @@ -49,25 +48,25 @@ libucontext_makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) switch (i) { case 0: - ucp->uc_mcontext.gregs[REG_RDI] = va_arg (va, greg_t); + ucp->uc_mcontext.gregs[REG_RDI] = va_arg (va, libucontext_greg_t); break; case 1: - ucp->uc_mcontext.gregs[REG_RSI] = va_arg (va, greg_t); + ucp->uc_mcontext.gregs[REG_RSI] = va_arg (va, libucontext_greg_t); break; case 2: - ucp->uc_mcontext.gregs[REG_RDX] = va_arg (va, greg_t); + ucp->uc_mcontext.gregs[REG_RDX] = va_arg (va, libucontext_greg_t); break; case 3: - ucp->uc_mcontext.gregs[REG_RCX] = va_arg (va, greg_t); + ucp->uc_mcontext.gregs[REG_RCX] = va_arg (va, libucontext_greg_t); break; case 4: - ucp->uc_mcontext.gregs[REG_R8] = va_arg (va, greg_t); + ucp->uc_mcontext.gregs[REG_R8] = va_arg (va, libucontext_greg_t); break; case 5: - ucp->uc_mcontext.gregs[REG_R9] = va_arg (va, greg_t); + ucp->uc_mcontext.gregs[REG_R9] = va_arg (va, libucontext_greg_t); break; default: - sp[i - 5] = va_arg (va, greg_t); + sp[i - 5] = va_arg (va, libucontext_greg_t); break; }