Changeset b4f1171 in mainline


Ignore:
Timestamp:
2019-02-03T14:56:13Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f99dbf
Parents:
a5c78a18
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-03 14:49:38)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-03 14:56:13)
Message:

Rename setjmp/longjmp to context_save/context_restore

Once upon a time, I renamed context_save/context_restore to
setjmp/longjmp with the reasoning that they are almost
the same as setjmp/longjmp. I never got rid of the "almost",
so it ended up being somewhat confusing.
This is just a late correction of the old change.

Location:
uspace/lib/c
Files:
13 edited

Legend:

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

    ra5c78a18 rb4f1171  
    3333#include <stdbool.h>
    3434
    35 int __setjmp(__context_t *ctx)
     35int __context_save(__context_t *ctx)
    3636{
    3737        return 0;
    3838}
    3939
    40 void __longjmp(__context_t *ctx, int val)
     40void __context_restore(__context_t *ctx, int val)
    4141{
    4242        while (true)
  • uspace/lib/c/arch/amd64/src/fibril.S

    ra5c78a18 rb4f1171  
    3737# pointed by the 1st argument. Returns 0 in RAX.
    3838#
    39 FUNCTION_BEGIN(__setjmp)
     39FUNCTION_BEGIN(__context_save)
    4040        movq (%rsp), %rdx     # the caller's return %eip
    4141
     
    5454        movq %rax, __CONTEXT_OFFSET_TLS(%rdi)
    5555
    56         xorq %rax, %rax                      # __setjmp returns 0
     56        xorq %rax, %rax                      # __context_save returns 0
    5757        ret
    58 FUNCTION_END(__setjmp)
     58FUNCTION_END(__context_save)
    5959
    6060## Restore current CPU context
     
    6363# pointed by the 1st argument. Returns second argument in RAX.
    6464#
    65 FUNCTION_BEGIN(__longjmp)
     65FUNCTION_BEGIN(__context_restore)
    6666        movq __CONTEXT_OFFSET_R15(%rdi), %r15
    6767        movq __CONTEXT_OFFSET_R14(%rdi), %r14
     
    8080        movq %rdi, %fs:0
    8181
    82         movq %rsi, %rax                      # __longjmp returns second argument
     82        movq %rsi, %rax                      # __context_restore returns second argument
    8383        ret
    84 FUNCTION_END(__longjmp)
     84FUNCTION_END(__context_restore)
    8585
  • uspace/lib/c/arch/arm32/src/fibril.S

    ra5c78a18 rb4f1171  
    3131.text
    3232
    33 FUNCTION_BEGIN(__setjmp)
     33FUNCTION_BEGIN(__context_save)
    3434        stmia r0!, {sp, lr}
    3535        stmia r0!, {r4-r11}
     
    3838        mov r0, #0
    3939        mov pc, lr
    40 FUNCTION_END(__setjmp)
     40FUNCTION_END(__context_save)
    4141
    42 FUNCTION_BEGIN(__longjmp)
     42FUNCTION_BEGIN(__context_restore)
    4343        ldmia r0!, {sp, lr}
    4444        ldmia r0!, {r4-r11}
     
    4747        mov r0, r1
    4848        mov pc, lr
    49 FUNCTION_END(__longjmp)
     49FUNCTION_END(__context_restore)
    5050
  • uspace/lib/c/arch/ia32/src/fibril.S

    ra5c78a18 rb4f1171  
    3737# pointed by the 1st argument. Returns 0 in EAX.
    3838#
    39 FUNCTION_BEGIN(__setjmp)
     39FUNCTION_BEGIN(__context_save)
    4040        movl 0(%esp), %eax  # the caller's return %eip
    4141        movl 4(%esp), %edx  # address of the context variable to save context to
     
    5353        movl %eax, __CONTEXT_OFFSET_TLS(%edx)   # tls -> ctx->tls
    5454
    55         xorl %eax, %eax         # __setjmp returns 0
     55        xorl %eax, %eax         # __context_save returns 0
    5656        ret
    57 FUNCTION_END(__setjmp)
     57FUNCTION_END(__context_save)
    5858
    5959## Restore saved CPU context
     
    6262# pointed by the 1st argument. Returns second argument in EAX.
    6363#
    64 FUNCTION_BEGIN(__longjmp)
     64FUNCTION_BEGIN(__context_restore)
    6565        movl 4(%esp), %eax  # address of the context variable to restore context from
    6666        movl 8(%esp), %ecx  # return value
     
    8282        movl %ecx, %eax
    8383        ret
    84 FUNCTION_END(__longjmp)
     84FUNCTION_END(__context_restore)
    8585
  • uspace/lib/c/arch/ia64/include/libarch/fibril.h

    ra5c78a18 rb4f1171  
    4343
    4444/*
    45  * __setjmp() and __longjmp() are both leaf procedures.
     45 * __context_save() and __context_restore() are both leaf procedures.
    4646 * No need to allocate scratch area.
    4747 */
  • uspace/lib/c/arch/ia64/src/fibril.S

    ra5c78a18 rb4f1171  
    3232.text
    3333
    34 FUNCTION_BEGIN(__setjmp)
     34FUNCTION_BEGIN(__context_save)
    3535        alloc loc0 = ar.pfs, 1, 49, 0, 0
    3636        mov loc1 = ar.unat ;;
     
    178178        mov ar.unat = loc1
    179179
    180         mov r8 = 0      /* __setjmp returns 0 */
     180        mov r8 = 0      /* __context_save returns 0 */
    181181        br.ret.sptk.many b0
    182 FUNCTION_END(__setjmp)
    183 
    184 FUNCTION_BEGIN(__longjmp)
     182FUNCTION_END(__context_save)
     183
     184FUNCTION_BEGIN(__context_restore)
    185185        alloc loc0 = ar.pfs, 2, 50, 0, 0 ;;
    186186
     
    335335        mov ar.unat = loc1
    336336
    337         mov r8 = in1                    /* __longjmp returns second argument */
     337        mov r8 = in1                    /* __context_restore returns second argument */
    338338        br.ret.sptk.many b0
    339 FUNCTION_END(__longjmp)
     339FUNCTION_END(__context_restore)
  • uspace/lib/c/arch/mips32/src/fibril.S

    ra5c78a18 rb4f1171  
    3535#include <libarch/fibril_context.h>
    3636
    37 FUNCTION_BEGIN(__setjmp)
     37FUNCTION_BEGIN(__context_save)
    3838        sw $s0, __CONTEXT_OFFSET_S0($a0)
    3939        sw $s1, __CONTEXT_OFFSET_S1($a0)
     
    8787        sw $sp, __CONTEXT_OFFSET_SP($a0)
    8888
    89         # __setjmp returns 0
     89        # __context_save returns 0
    9090        j $ra
    9191        li $v0, 0
    92 FUNCTION_END(__setjmp)
     92FUNCTION_END(__context_save)
    9393
    94 FUNCTION_BEGIN(__longjmp)
     94FUNCTION_BEGIN(__context_restore)
    9595        lw $s0, __CONTEXT_OFFSET_S0($a0)
    9696        lw $s1, __CONTEXT_OFFSET_S1($a0)
     
    147147        move $t9, $ra
    148148
    149         # __longjmp returns second argument
     149        # __context_restore returns second argument
    150150        j $ra
    151151        move $v0, $a1
    152 FUNCTION_END(__longjmp)
     152FUNCTION_END(__context_restore)
  • uspace/lib/c/arch/ppc32/src/fibril.S

    ra5c78a18 rb4f1171  
    3333#include <libarch/fibril_context.h>
    3434
    35 FUNCTION_BEGIN(__setjmp)
     35FUNCTION_BEGIN(__context_save)
    3636        stw sp, __CONTEXT_OFFSET_SP(r3)
    3737        stw r2, __CONTEXT_OFFSET_TLS(r3)
     
    6262        stw r4, __CONTEXT_OFFSET_CR(r3)
    6363
    64         # __setjmp returns 0
     64        # __context_save returns 0
    6565        li r3, 0
    6666        blr
    67 FUNCTION_END(__setjmp)
     67FUNCTION_END(__context_save)
    6868
    69 FUNCTION_BEGIN(__longjmp)
     69FUNCTION_BEGIN(__context_restore)
    7070        lwz sp, __CONTEXT_OFFSET_SP(r3)
    7171        lwz r2, __CONTEXT_OFFSET_TLS(r3)
     
    9696        mtlr r5
    9797
    98         # __longjmp returns second argument
     98        # __context_restore returns second argument
    9999        mr r3, r4
    100100        blr
    101 FUNCTION_END(__longjmp)
     101FUNCTION_END(__context_restore)
  • uspace/lib/c/arch/riscv64/src/fibril.c

    ra5c78a18 rb4f1171  
    3333#include <stdbool.h>
    3434
    35 int __setjmp(__context_t *ctx)
     35int __context_save(__context_t *ctx)
    3636{
    3737        return 0;
    3838}
    3939
    40 void __longjmp(__context_t *ctx, int ret)
     40void __context_restore(__context_t *ctx, int ret)
    4141{
    4242        while (true)
  • uspace/lib/c/arch/sparc64/src/fibril.S

    ra5c78a18 rb4f1171  
    3232.text
    3333
    34 FUNCTION_BEGIN(__setjmp)
     34FUNCTION_BEGIN(__context_save)
    3535        #
    3636        # We rely on the kernel to flush our active register windows to memory
     
    5757        stx %g7, [%o0 + __CONTEXT_OFFSET_TP]
    5858        retl
    59         mov 0, %o0              ! __setjmp returns 0
    60 FUNCTION_END(__setjmp)
     59        mov 0, %o0              ! __context_save returns 0
     60FUNCTION_END(__context_save)
    6161
    62 FUNCTION_BEGIN(__longjmp)
     62FUNCTION_BEGIN(__context_restore)
    6363        #
    6464        # Flush all active windows.
     
    8989        ldx [%o0 + __CONTEXT_OFFSET_TP], %g7
    9090        retl
    91         mov %o1, %o0    ! __longjmp returns second argument
    92 FUNCTION_END(__longjmp)
     91        mov %o1, %o0    ! __context_restore returns second argument
     92FUNCTION_END(__context_restore)
  • uspace/lib/c/generic/context.c

    ra5c78a18 rb4f1171  
    4343void context_swap(context_t *self, context_t *other)
    4444{
    45         if (!__setjmp(self))
    46                 __longjmp(other, 1);
     45        if (!__context_save(self))
     46                __context_restore(other, 1);
    4747}
    4848
    4949void context_create(context_t *context, const context_create_t *arg)
    5050{
    51         __setjmp(context);
     51        __context_save(context);
    5252        context_set(context, FADDR(arg->fn), arg->stack_base,
    5353            arg->stack_size, arg->tls);
  • uspace/lib/c/generic/setjmp.c

    ra5c78a18 rb4f1171  
    3838void longjmp(jmp_buf env, int val)
    3939{
    40         /* __longjmp defined in assembly doesn't "correct" the value. */
    41         __longjmp(env, val == 0 ? 1 : val);
     40        /*
     41         * The standard requires that longjmp() ensures that val is not zero.
     42         * __context_restore doesn't do that, so we do it here.
     43         */
     44        __context_restore(env, val == 0 ? 1 : val);
    4245}
    4346
  • uspace/lib/c/include/setjmp.h

    ra5c78a18 rb4f1171  
    4343typedef __context_t jmp_buf[1];
    4444
    45 extern int __setjmp(jmp_buf) __attribute__((returns_twice));
    46 extern __noreturn void __longjmp(jmp_buf, int);
     45extern int __context_save(__context_t *) __attribute__((returns_twice));
     46extern __noreturn void __context_restore(__context_t *, int);
    4747
    48 #define setjmp __setjmp
     48#define setjmp __context_save
    4949extern __noreturn void longjmp(jmp_buf, int);
    5050
Note: See TracChangeset for help on using the changeset viewer.