libc: aarch64 setjmp, untested
This commit is contained in:
parent
0621fa81b6
commit
491849427b
@ -5,7 +5,11 @@
|
||||
_Begin_C_Header
|
||||
|
||||
/* i386 */
|
||||
#ifdef __aarch64__
|
||||
#define _JBLEN 32
|
||||
#else
|
||||
#define _JBLEN 9
|
||||
#endif
|
||||
|
||||
typedef long long jmp_buf[_JBLEN];
|
||||
|
||||
|
43
libc/arch/aarch64/setjmp.c
Normal file
43
libc/arch/aarch64/setjmp.c
Normal file
@ -0,0 +1,43 @@
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
asm (
|
||||
".globl setjmp\n"
|
||||
"setjmp:\n"
|
||||
"mov x2, sp\n"
|
||||
"stp x2, x29, [x0]\n"
|
||||
"stp x30, x1, [x0, (1 * 16)]\n"
|
||||
"stp x19, x20, [x0, (2 * 16)]\n"
|
||||
"stp x21, x22, [x0, (3 * 16)]\n"
|
||||
"stp x23, x24, [x0, (4 * 16)]\n"
|
||||
"stp x25, x26, [x0, (5 * 16)]\n"
|
||||
"stp x27, x28, [x0, (6 * 16)]\n"
|
||||
"mov x0, 0\n"
|
||||
"ret\n"
|
||||
".globl longjmp\n"
|
||||
"longjmp:\n"
|
||||
"ldp x2, x29, [x0]\n"
|
||||
"ldp x30, x1, [x0, (1 * 16)]\n"
|
||||
"ldp x19, x20, [x0, (2 * 16)]\n"
|
||||
"ldp x21, x22, [x0, (3 * 16)]\n"
|
||||
"ldp x23, x24, [x0, (4 * 16)]\n"
|
||||
"ldp x25, x26, [x0, (5 * 16)]\n"
|
||||
"ldp x27, x28, [x0, (6 * 16)]\n"
|
||||
"mov sp, x2\n"
|
||||
"mov x0, 1\n"
|
||||
"ret\n"
|
||||
);
|
||||
|
||||
#if 0
|
||||
int _setjmp(jmp_buf env);
|
||||
void _longjmp(jmp_buf env, int val);
|
||||
|
||||
int setjmp(jmp_buf env) {
|
||||
fprintf(stderr, "setjmp called\n");
|
||||
return _setjmp(env);
|
||||
}
|
||||
void longjmp(jmp_buf env, int val) {
|
||||
fprintf(stderr, "longjmp called\n");
|
||||
_longjmp(env,val);
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user