Skip to content

Q: Why this? #51

@TurkeyMan

Description

@TurkeyMan

Help me understand this line?

libco/x86.c

Lines 99 to 100 in e18e09d

stack_top -= 32;
stack_top &= ~((unsigned long) 15);

libco/amd64.c

Lines 143 to 144 in e18e09d

stack_top -= 32;
stack_top &= ~((unsigned long long) 15);

It's obvious why it aligns down by 16 bytes, but why subtract 32? It looks arbitrary; nothing is ever written there (?), so why are we wasting them here?

Also, check the ARM version:

libco/arm.c

Lines 24 to 28 in e18e09d

static const unsigned long co_swap_function[1024] = {
0xe8a16ff0, /* stmia r1!, {r4-r11,sp,lr} */
0xe8b0aff0, /* ldmia r0!, {r4-r11,sp,pc} */
0xe12fff1e, /* bx lr */
};

Why is that final bx lr instruction there? The line before loads pc, that should be unreachable code... is there a reason?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions