Changeset b4f1171 in mainline
- Timestamp:
- 2019-02-03T14:56:13Z (6 years ago)
- 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)
- Location:
- uspace/lib/c
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/abs32le/src/fibril.c
ra5c78a18 rb4f1171 33 33 #include <stdbool.h> 34 34 35 int __ setjmp(__context_t *ctx)35 int __context_save(__context_t *ctx) 36 36 { 37 37 return 0; 38 38 } 39 39 40 void __ longjmp(__context_t *ctx, int val)40 void __context_restore(__context_t *ctx, int val) 41 41 { 42 42 while (true) -
uspace/lib/c/arch/amd64/src/fibril.S
ra5c78a18 rb4f1171 37 37 # pointed by the 1st argument. Returns 0 in RAX. 38 38 # 39 FUNCTION_BEGIN(__ setjmp)39 FUNCTION_BEGIN(__context_save) 40 40 movq (%rsp), %rdx # the caller's return %eip 41 41 … … 54 54 movq %rax, __CONTEXT_OFFSET_TLS(%rdi) 55 55 56 xorq %rax, %rax # __ setjmpreturns 056 xorq %rax, %rax # __context_save returns 0 57 57 ret 58 FUNCTION_END(__ setjmp)58 FUNCTION_END(__context_save) 59 59 60 60 ## Restore current CPU context … … 63 63 # pointed by the 1st argument. Returns second argument in RAX. 64 64 # 65 FUNCTION_BEGIN(__ longjmp)65 FUNCTION_BEGIN(__context_restore) 66 66 movq __CONTEXT_OFFSET_R15(%rdi), %r15 67 67 movq __CONTEXT_OFFSET_R14(%rdi), %r14 … … 80 80 movq %rdi, %fs:0 81 81 82 movq %rsi, %rax # __ longjmpreturns second argument82 movq %rsi, %rax # __context_restore returns second argument 83 83 ret 84 FUNCTION_END(__ longjmp)84 FUNCTION_END(__context_restore) 85 85 -
uspace/lib/c/arch/arm32/src/fibril.S
ra5c78a18 rb4f1171 31 31 .text 32 32 33 FUNCTION_BEGIN(__ setjmp)33 FUNCTION_BEGIN(__context_save) 34 34 stmia r0!, {sp, lr} 35 35 stmia r0!, {r4-r11} … … 38 38 mov r0, #0 39 39 mov pc, lr 40 FUNCTION_END(__ setjmp)40 FUNCTION_END(__context_save) 41 41 42 FUNCTION_BEGIN(__ longjmp)42 FUNCTION_BEGIN(__context_restore) 43 43 ldmia r0!, {sp, lr} 44 44 ldmia r0!, {r4-r11} … … 47 47 mov r0, r1 48 48 mov pc, lr 49 FUNCTION_END(__ longjmp)49 FUNCTION_END(__context_restore) 50 50 -
uspace/lib/c/arch/ia32/src/fibril.S
ra5c78a18 rb4f1171 37 37 # pointed by the 1st argument. Returns 0 in EAX. 38 38 # 39 FUNCTION_BEGIN(__ setjmp)39 FUNCTION_BEGIN(__context_save) 40 40 movl 0(%esp), %eax # the caller's return %eip 41 41 movl 4(%esp), %edx # address of the context variable to save context to … … 53 53 movl %eax, __CONTEXT_OFFSET_TLS(%edx) # tls -> ctx->tls 54 54 55 xorl %eax, %eax # __ setjmpreturns 055 xorl %eax, %eax # __context_save returns 0 56 56 ret 57 FUNCTION_END(__ setjmp)57 FUNCTION_END(__context_save) 58 58 59 59 ## Restore saved CPU context … … 62 62 # pointed by the 1st argument. Returns second argument in EAX. 63 63 # 64 FUNCTION_BEGIN(__ longjmp)64 FUNCTION_BEGIN(__context_restore) 65 65 movl 4(%esp), %eax # address of the context variable to restore context from 66 66 movl 8(%esp), %ecx # return value … … 82 82 movl %ecx, %eax 83 83 ret 84 FUNCTION_END(__ longjmp)84 FUNCTION_END(__context_restore) 85 85 -
uspace/lib/c/arch/ia64/include/libarch/fibril.h
ra5c78a18 rb4f1171 43 43 44 44 /* 45 * __ setjmp() and __longjmp() are both leaf procedures.45 * __context_save() and __context_restore() are both leaf procedures. 46 46 * No need to allocate scratch area. 47 47 */ -
uspace/lib/c/arch/ia64/src/fibril.S
ra5c78a18 rb4f1171 32 32 .text 33 33 34 FUNCTION_BEGIN(__ setjmp)34 FUNCTION_BEGIN(__context_save) 35 35 alloc loc0 = ar.pfs, 1, 49, 0, 0 36 36 mov loc1 = ar.unat ;; … … 178 178 mov ar.unat = loc1 179 179 180 mov r8 = 0 /* __ setjmpreturns 0 */180 mov r8 = 0 /* __context_save returns 0 */ 181 181 br.ret.sptk.many b0 182 FUNCTION_END(__ setjmp)183 184 FUNCTION_BEGIN(__ longjmp)182 FUNCTION_END(__context_save) 183 184 FUNCTION_BEGIN(__context_restore) 185 185 alloc loc0 = ar.pfs, 2, 50, 0, 0 ;; 186 186 … … 335 335 mov ar.unat = loc1 336 336 337 mov r8 = in1 /* __ longjmpreturns second argument */337 mov r8 = in1 /* __context_restore returns second argument */ 338 338 br.ret.sptk.many b0 339 FUNCTION_END(__ longjmp)339 FUNCTION_END(__context_restore) -
uspace/lib/c/arch/mips32/src/fibril.S
ra5c78a18 rb4f1171 35 35 #include <libarch/fibril_context.h> 36 36 37 FUNCTION_BEGIN(__ setjmp)37 FUNCTION_BEGIN(__context_save) 38 38 sw $s0, __CONTEXT_OFFSET_S0($a0) 39 39 sw $s1, __CONTEXT_OFFSET_S1($a0) … … 87 87 sw $sp, __CONTEXT_OFFSET_SP($a0) 88 88 89 # __ setjmpreturns 089 # __context_save returns 0 90 90 j $ra 91 91 li $v0, 0 92 FUNCTION_END(__ setjmp)92 FUNCTION_END(__context_save) 93 93 94 FUNCTION_BEGIN(__ longjmp)94 FUNCTION_BEGIN(__context_restore) 95 95 lw $s0, __CONTEXT_OFFSET_S0($a0) 96 96 lw $s1, __CONTEXT_OFFSET_S1($a0) … … 147 147 move $t9, $ra 148 148 149 # __ longjmpreturns second argument149 # __context_restore returns second argument 150 150 j $ra 151 151 move $v0, $a1 152 FUNCTION_END(__ longjmp)152 FUNCTION_END(__context_restore) -
uspace/lib/c/arch/ppc32/src/fibril.S
ra5c78a18 rb4f1171 33 33 #include <libarch/fibril_context.h> 34 34 35 FUNCTION_BEGIN(__ setjmp)35 FUNCTION_BEGIN(__context_save) 36 36 stw sp, __CONTEXT_OFFSET_SP(r3) 37 37 stw r2, __CONTEXT_OFFSET_TLS(r3) … … 62 62 stw r4, __CONTEXT_OFFSET_CR(r3) 63 63 64 # __ setjmpreturns 064 # __context_save returns 0 65 65 li r3, 0 66 66 blr 67 FUNCTION_END(__ setjmp)67 FUNCTION_END(__context_save) 68 68 69 FUNCTION_BEGIN(__ longjmp)69 FUNCTION_BEGIN(__context_restore) 70 70 lwz sp, __CONTEXT_OFFSET_SP(r3) 71 71 lwz r2, __CONTEXT_OFFSET_TLS(r3) … … 96 96 mtlr r5 97 97 98 # __ longjmpreturns second argument98 # __context_restore returns second argument 99 99 mr r3, r4 100 100 blr 101 FUNCTION_END(__ longjmp)101 FUNCTION_END(__context_restore) -
uspace/lib/c/arch/riscv64/src/fibril.c
ra5c78a18 rb4f1171 33 33 #include <stdbool.h> 34 34 35 int __ setjmp(__context_t *ctx)35 int __context_save(__context_t *ctx) 36 36 { 37 37 return 0; 38 38 } 39 39 40 void __ longjmp(__context_t *ctx, int ret)40 void __context_restore(__context_t *ctx, int ret) 41 41 { 42 42 while (true) -
uspace/lib/c/arch/sparc64/src/fibril.S
ra5c78a18 rb4f1171 32 32 .text 33 33 34 FUNCTION_BEGIN(__ setjmp)34 FUNCTION_BEGIN(__context_save) 35 35 # 36 36 # We rely on the kernel to flush our active register windows to memory … … 57 57 stx %g7, [%o0 + __CONTEXT_OFFSET_TP] 58 58 retl 59 mov 0, %o0 ! __ setjmpreturns 060 FUNCTION_END(__ setjmp)59 mov 0, %o0 ! __context_save returns 0 60 FUNCTION_END(__context_save) 61 61 62 FUNCTION_BEGIN(__ longjmp)62 FUNCTION_BEGIN(__context_restore) 63 63 # 64 64 # Flush all active windows. … … 89 89 ldx [%o0 + __CONTEXT_OFFSET_TP], %g7 90 90 retl 91 mov %o1, %o0 ! __ longjmpreturns second argument92 FUNCTION_END(__ longjmp)91 mov %o1, %o0 ! __context_restore returns second argument 92 FUNCTION_END(__context_restore) -
uspace/lib/c/generic/context.c
ra5c78a18 rb4f1171 43 43 void context_swap(context_t *self, context_t *other) 44 44 { 45 if (!__ setjmp(self))46 __ longjmp(other, 1);45 if (!__context_save(self)) 46 __context_restore(other, 1); 47 47 } 48 48 49 49 void context_create(context_t *context, const context_create_t *arg) 50 50 { 51 __ setjmp(context);51 __context_save(context); 52 52 context_set(context, FADDR(arg->fn), arg->stack_base, 53 53 arg->stack_size, arg->tls); -
uspace/lib/c/generic/setjmp.c
ra5c78a18 rb4f1171 38 38 void longjmp(jmp_buf env, int val) 39 39 { 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); 42 45 } 43 46 -
uspace/lib/c/include/setjmp.h
ra5c78a18 rb4f1171 43 43 typedef __context_t jmp_buf[1]; 44 44 45 extern int __ setjmp(jmp_buf) __attribute__((returns_twice));46 extern __noreturn void __ longjmp(jmp_buf, int);45 extern int __context_save(__context_t *) __attribute__((returns_twice)); 46 extern __noreturn void __context_restore(__context_t *, int); 47 47 48 #define setjmp __ setjmp48 #define setjmp __context_save 49 49 extern __noreturn void longjmp(jmp_buf, int); 50 50
Note:
See TracChangeset
for help on using the changeset viewer.