Changeset a35a3d8 in mainline for uspace/lib/c/arch/ppc32/src/fibril.S


Ignore:
Timestamp:
2018-03-12T17:13:46Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b127e4af
Parents:
f3d47c97
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-12 17:13:46)
git-committer:
GitHub <noreply@…> (2018-03-12 17:13:46)
Message:

Turn context_save/context_restore into standard setjmp/longjmp. (#24)

Turn context_save()/context_restore() into semi-standard __setjmp()/__longjmp().

The original context_* functions are similar to setjmp()/longjmp(), except that the return value is more restricted for the former, and with inverted meaning. This commit adopts the standard return value semantics and acknowledges that these functions are "standard setjmp()/longjmp() with additional implementation-specific properties" by changing the name. The only divergence from the standard is that __longjmp() causes __setjmp() to return its value unchanged, even if it is zero. This is just to avoid extra assembly, and longjmp() checks this in C.

Note that the original use of context_save()/context_restore() to implement context switching in fibril implementation has already been delegated to context_create()/context_swap(), which provide more natural control flow.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/arch/ppc32/src/fibril.S

    rf3d47c97 ra35a3d8  
    3333#include <libarch/fibril_context.h>
    3434
    35 FUNCTION_BEGIN(context_save)
     35FUNCTION_BEGIN(__setjmp)
    3636        stw sp, CONTEXT_OFFSET_SP(r3)
    3737        stw r2, CONTEXT_OFFSET_TLS(r3)
     
    6262        stw r4, CONTEXT_OFFSET_CR(r3)
    6363
    64         # context_save returns 1
    65         li r3, 1
     64        # __setjmp returns 0
     65        li r3, 0
    6666        blr
    67 FUNCTION_END(context_save)
     67FUNCTION_END(__setjmp)
    6868
    69 FUNCTION_BEGIN(context_restore)
     69FUNCTION_BEGIN(__longjmp)
    7070        lwz sp, CONTEXT_OFFSET_SP(r3)
    7171        lwz r2, CONTEXT_OFFSET_TLS(r3)
     
    9090        lwz r31, CONTEXT_OFFSET_R31(r3)
    9191
    92         lwz r4, CONTEXT_OFFSET_CR(r3)
    93         mtcr r4
     92        lwz r5, CONTEXT_OFFSET_CR(r3)
     93        mtcr r5
    9494
    95         lwz r4, CONTEXT_OFFSET_PC(r3)
    96         mtlr r4
     95        lwz r5, CONTEXT_OFFSET_PC(r3)
     96        mtlr r5
    9797
    98         # context_restore returns 0
    99         li r3, 0
     98        # __longjmp returns second argument
     99        mr r3, r4
    100100        blr
    101 FUNCTION_END(context_restore)
     101FUNCTION_END(__longjmp)
Note: See TracChangeset for help on using the changeset viewer.