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


Ignore:
Timestamp:
2018-03-12T17:13:46Z (6 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/arm32/src/fibril.S

    rf3d47c97 ra35a3d8  
    3131.text
    3232
    33 FUNCTION_BEGIN(context_save)
     33FUNCTION_BEGIN(__setjmp)
    3434        stmia r0!, {sp, lr}
    3535        stmia r0!, {r4-r11}
    36 
    37         # return 1
    38         mov r0, #1
    39         mov pc, lr
    40 FUNCTION_END(context_save)
    41 
    42 FUNCTION_BEGIN(context_restore)
    43         ldmia r0!, {sp, lr}
    44         ldmia r0!, {r4-r11}
    4536
    4637        # return 0
    4738        mov r0, #0
    4839        mov pc, lr
    49 FUNCTION_END(context_restore)
     40FUNCTION_END(__setjmp)
    5041
     42FUNCTION_BEGIN(__longjmp)
     43        ldmia r0!, {sp, lr}
     44        ldmia r0!, {r4-r11}
     45
     46        # return second argument
     47        mov r0, r1
     48        mov pc, lr
     49FUNCTION_END(__longjmp)
     50
Note: See TracChangeset for help on using the changeset viewer.