ppc32/64: simplify storage of stack parameters

The switch statement is simpler as an if/else, and removing the argp
variable makes the code more symmetric between the register and stack
parameter cases.
pull/11/head
Bobby Bingham 2019-04-05 13:57:53 -05:00
parent b500b054c7
commit 55168fcb18
2 changed files with 12 additions and 36 deletions

View File

@ -27,7 +27,7 @@ extern void __start_context(void);
void void
__makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{ {
greg_t *sp, *argp; greg_t *sp;
va_list va; va_list va;
int i; int i;
unsigned int stack_args; unsigned int stack_args;
@ -44,26 +44,14 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
ucp->uc_mcontext.gregs[REG_SP] = (uintptr_t) sp; ucp->uc_mcontext.gregs[REG_SP] = (uintptr_t) sp;
sp[0] = 0; sp[0] = 0;
argp = &sp[2];
va_start(va, argc); va_start(va, argc);
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++) {
switch (i) if (i < 8)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
ucp->uc_mcontext.gregs[i + 3] = va_arg (va, greg_t); ucp->uc_mcontext.gregs[i + 3] = va_arg (va, greg_t);
break; else
default: sp[i-8 + 2] = va_arg (va, greg_t);
*argp++ = va_arg (va, greg_t);
break;
} }
va_end(va); va_end(va);

View File

@ -27,7 +27,7 @@ extern void __start_context(void);
void void
__makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{ {
greg_t *sp, *argp; greg_t *sp;
va_list va; va_list va;
int i; int i;
unsigned int stack_args; unsigned int stack_args;
@ -45,26 +45,14 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
ucp->uc_mcontext.gp_regs[REG_R31] = (uintptr_t) ucp->uc_link; ucp->uc_mcontext.gp_regs[REG_R31] = (uintptr_t) ucp->uc_link;
sp[0] = 0; sp[0] = 0;
argp = &sp[2];
va_start(va, argc); va_start(va, argc);
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++) {
switch (i) if (i < 8)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
ucp->uc_mcontext.gp_regs[i + 3] = va_arg (va, greg_t); ucp->uc_mcontext.gp_regs[i + 3] = va_arg (va, greg_t);
break; else
default: sp[i-8 + 2] = va_arg (va, greg_t);
*argp++ = va_arg (va, greg_t);
break;
} }
va_end(va); va_end(va);