Changeset a35a3d8 in mainline for uspace/lib/c/arch/ia64/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/ia64/src/fibril.S

    rf3d47c97 ra35a3d8  
    3232.text
    3333
    34 FUNCTION_BEGIN(context_save)
     34FUNCTION_BEGIN(__setjmp)
    3535        alloc loc0 = ar.pfs, 1, 49, 0, 0
    3636        mov loc1 = ar.unat ;;
     
    178178        mov ar.unat = loc1
    179179
    180         add r8 = r0, r0, 1      /* context_save returns 1 */
     180        mov r8 = 0      /* __setjmp returns 0 */
    181181        br.ret.sptk.many b0
    182 FUNCTION_END(context_save)
    183 
    184 FUNCTION_BEGIN(context_restore)
    185         alloc loc0 = ar.pfs, 1, 50, 0, 0        ;;
     182FUNCTION_END(__setjmp)
     183
     184FUNCTION_BEGIN(__longjmp)
     185        alloc loc0 = ar.pfs, 2, 51, 0, 0        ;;
    186186
    187187        add loc9 = CONTEXT_OFFSET_AR_PFS, in0
     
    230230        add loc47 = CONTEXT_OFFSET_F29, in0
    231231        add loc48 = CONTEXT_OFFSET_F30, in0
    232         add loc49 = CONTEXT_OFFSET_F31, in0 ;;
     232        add loc49 = CONTEXT_OFFSET_F31, in0
     233        mov loc50 = in1 ;;
    233234
    234235        ld8 loc0 = [loc9]       /* load ar.pfs */
     
    335336        mov ar.unat = loc1
    336337
    337         mov r8 = r0                     /* context_restore returns 0 */
     338        mov r8 = loc50                  /* __longjmp returns second argument */
    338339        br.ret.sptk.many b0
    339 FUNCTION_END(context_restore)
     340FUNCTION_END(__longjmp)
Note: See TracChangeset for help on using the changeset viewer.