ulib setjmp() and longjmp()
This commit is contained in:
@ -17,6 +17,7 @@ SRCFILES := $(call GRABSRC, \
|
|||||||
umalloc \
|
umalloc \
|
||||||
fs \
|
fs \
|
||||||
time \
|
time \
|
||||||
|
jump \
|
||||||
)
|
)
|
||||||
|
|
||||||
CFLAGS += -isystem $(ROOT)/share -isystem $(ROOT)/ulib -isystem $(ROOT)/std/include \
|
CFLAGS += -isystem $(ROOT)/share -isystem $(ROOT)/ulib -isystem $(ROOT)/std/include \
|
||||||
|
|||||||
33
ulib/jump/jump.S
Normal file
33
ulib/jump/jump.S
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// https://patchwork.ozlabs.org/project/uboot/patch/c315e41d155612260223ef75afa06bd728a3e705.1529433258.git.ivan.gorinov@intel.com/
|
||||||
|
|
||||||
|
.global setjmp
|
||||||
|
setjmp:
|
||||||
|
pop %rcx
|
||||||
|
movq %rcx, (%rdi)
|
||||||
|
movq %rsp, 8(%rdi)
|
||||||
|
movq %rbp, 16(%rdi)
|
||||||
|
movq %rbx, 24(%rdi)
|
||||||
|
movq %r12, 32(%rdi)
|
||||||
|
movq %r13, 40(%rdi)
|
||||||
|
movq %r14, 48(%rdi)
|
||||||
|
movq %r15, 56(%rdi)
|
||||||
|
xorq %rax, %rax
|
||||||
|
jmpq *%rcx
|
||||||
|
|
||||||
|
.global longjmp
|
||||||
|
longjmp:
|
||||||
|
movq (%rdi), %rcx
|
||||||
|
movq 8(%rdi), %rsp
|
||||||
|
movq 16(%rdi), %rbp
|
||||||
|
movq 24(%rdi), %rbx
|
||||||
|
movq 32(%rdi), %r12
|
||||||
|
movq 40(%rdi), %r13
|
||||||
|
movq 48(%rdi), %r14
|
||||||
|
movq 56(%rdi), %r15
|
||||||
|
|
||||||
|
movq %rsi, %rax
|
||||||
|
testq %rax, %rax
|
||||||
|
jnz 1f
|
||||||
|
incq %rax
|
||||||
|
1:
|
||||||
|
jmpq *%rcx
|
||||||
23
ulib/jump/jump.h
Normal file
23
ulib/jump/jump.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef ULIB_JUMP_JUMP_H_
|
||||||
|
#define ULIB_JUMP_JUMP_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/* typedef struct { */
|
||||||
|
/* uint64_t rip; */
|
||||||
|
/* uint64_t rsp; */
|
||||||
|
/* uint64_t rbp; */
|
||||||
|
/* uint64_t rbx; */
|
||||||
|
/* uint64_t r12; */
|
||||||
|
/* uint64_t r13; */
|
||||||
|
/* uint64_t r14; */
|
||||||
|
/* uint64_t r15; */
|
||||||
|
/* } JumpEnv; */
|
||||||
|
|
||||||
|
typedef uint64_t jmp_buf[8];
|
||||||
|
|
||||||
|
int setjmp(jmp_buf env);
|
||||||
|
void longjmp(jmp_buf env, int status);
|
||||||
|
|
||||||
|
#endif // ULIB_JUMP_JUMP_H_
|
||||||
6
ulib/setjmp.h
Normal file
6
ulib/setjmp.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef ULIB_SETJMP_H_
|
||||||
|
#define ULIB_SETJMP_H_
|
||||||
|
|
||||||
|
#include <jump/jump.h>
|
||||||
|
|
||||||
|
#endif // ULIB_SETJMP_H_
|
||||||
Reference in New Issue
Block a user