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.
arm_linker_fix
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
__makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
{
greg_t *sp, *argp;
greg_t *sp;
va_list va;
int i;
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;
sp[0] = 0;
argp = &sp[2];
va_start(va, argc);
for (i = 0; i < argc; i++)
switch (i)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
for (i = 0; i < argc; i++) {
if (i < 8)
ucp->uc_mcontext.gregs[i + 3] = va_arg (va, greg_t);
break;
default:
*argp++ = va_arg (va, greg_t);
break;
else
sp[i-8 + 2] = va_arg (va, greg_t);
}
va_end(va);

View File

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