Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Compile vppinfra on macOS
[vpp.git]
/
src
/
vppinfra
/
longjmp.S
diff --git
a/src/vppinfra/longjmp.S
b/src/vppinfra/longjmp.S
index
6468dba
..
0b7449f
100644
(file)
--- a/
src/vppinfra/longjmp.S
+++ b/
src/vppinfra/longjmp.S
@@
-34,12
+34,21
@@
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-
+
+#if defined(__APPLE__)
+# define cdecl(s) _##s
+#else
+# define cdecl(s) s
+#endif
+
#if defined(__x86_64__)
#if defined(__x86_64__)
- .global c
lib_setjmp
+ .global c
decl(clib_setjmp)
.align 4
.align 4
- .type clib_setjmp, @function
-clib_setjmp:
+#ifndef __APPLE__
+ .type cdecl(clib_setjmp), @function
+#endif
+
+cdecl(clib_setjmp):
movq %rbx, 8*0(%rdi)
movq %rbp, 8*1(%rdi)
movq %r12, 8*2(%rdi)
movq %rbx, 8*0(%rdi)
movq %rbp, 8*1(%rdi)
movq %r12, 8*2(%rdi)
@@
-59,10
+68,12
@@
clib_setjmp:
movq %rsi, %rax
ret
movq %rsi, %rax
ret
- .global c
lib_longjmp
+ .global c
decl(clib_longjmp)
.align 4
.align 4
- .type clib_longjmp, @function
-clib_longjmp:
+#ifndef __APPLE__
+ .type cdecl(clib_longjmp), @function
+#endif
+cdecl(clib_longjmp):
/* Restore regs. */
movq 8*0(%rdi), %rbx
movq 8*1(%rdi), %rbp
/* Restore regs. */
movq 8*0(%rdi), %rbx
movq 8*1(%rdi), %rbp
@@
-79,10
+90,12
@@
clib_longjmp:
/* Away we go. */
jmpq *%rdx
/* Away we go. */
jmpq *%rdx
- .global c
lib_calljmp
+ .global c
decl(clib_calljmp)
.align 4
.align 4
- .type clib_calljmp, @function
-clib_calljmp:
+#ifndef __APPLE__
+ .type cdecl(clib_calljmp), @function
+#endif
+cdecl(clib_calljmp):
/* Make sure stack is 16-byte aligned. */
movq %rdx, %rax
andq $0xf, %rax
/* Make sure stack is 16-byte aligned. */
movq %rdx, %rax
andq $0xf, %rax
@@
-118,10
+131,10
@@
clib_calljmp:
jmpq *%rdx
#elif defined(i386)
jmpq *%rdx
#elif defined(i386)
- .global c
lib_setjmp
+ .global c
decl(clib_setjmp)
.align 4
.align 4
- .type c
lib_setjmp
, @function
-c
lib_setjmp
:
+ .type c
decl(clib_setjmp)
, @function
+c
decl(clib_setjmp)
:
movl 4(%esp), %ecx
movl %ebp, 4*0(%ecx)
movl 4(%esp), %ecx
movl %ebp, 4*0(%ecx)
@@
-141,10
+154,10
@@
clib_setjmp:
movl 8(%esp), %eax
ret
movl 8(%esp), %eax
ret
- .global c
lib_longjmp
+ .global c
decl(clib_longjmp)
.align 4
.align 4
- .type c
lib_longjmp
, @function
-c
lib_longjmp:
+ .type c
decl(clib_longjmp)
, @function
+c
decl(clib_longjmp):
movl 4(%esp), %ecx
/* Give back user's return value. */
movl 4(%esp), %ecx
/* Give back user's return value. */
@@
-161,10
+174,10
@@
clib_longjmp:
/* Away we go. */
jmp *%edx
/* Away we go. */
jmp *%edx
- .global c
lib_calljmp
+ .global c
decl(clib_calljmp)
.align 4
.align 4
- .type c
lib_calljmp
, @function
-c
lib_calljmp:
+ .type c
decl(clib_calljmp)
, @function
+c
decl(clib_calljmp):
/* Get new stack pointer. */
movl 12(%esp), %edx
/* Get new stack pointer. */
movl 12(%esp), %edx
@@
-224,7
+237,7
@@
_ (26, 6) _ (27, 7) _ (28, 8) _ (29, 9) _ (30, 10) _ (31, 11)
#define CLIB_POWERPC_ALTIVEC_N_REGS 0
#endif
#define CLIB_POWERPC_ALTIVEC_N_REGS 0
#endif
-_prologue (c
lib_setjmp
)
+_prologue (c
decl(clib_setjmp)
)
mflr 0
std 0, 8*0(3)
std 1, 8*1(3)
mflr 0
std 0, 8*0(3)
std 1, 8*1(3)
@@
-257,7
+270,7
@@
_prologue (clib_setjmp)
blr
blr
-_prologue (c
lib_longjmp
)
+_prologue (c
decl(clib_longjmp)
)
ld 0, 8*0(3)
mtlr 0
ld 1, 8*1(3)
ld 0, 8*0(3)
mtlr 0
ld 1, 8*1(3)
@@
-290,14
+303,14
@@
_prologue (clib_longjmp)
blr
blr
- .globl c
lib_calljmp
+ .globl c
decl(clib_calljmp)
.section ".opd","aw"
.align 3
.section ".opd","aw"
.align 3
-c
lib_calljmp
:
- .quad .L.c
lib_calljmp
,.TOC.@tocbase,0
+c
decl(clib_calljmp)
:
+ .quad .L.c
decl(clib_calljmp)
,.TOC.@tocbase,0
.previous
.previous
- .type c
lib_calljmp
, @function
-.L.c
lib_calljmp
:
+ .type c
decl(clib_calljmp)
, @function
+.L.c
decl(clib_calljmp)
:
mflr 0
mr 9,3
std 0,16(1)
mflr 0
mr 9,3
std 0,16(1)
@@
-325,7
+338,7
@@
clib_calljmp:
blr
.long 0
.byte 0,0,0,1,128,0,0,0
blr
.long 0
.byte 0,0,0,1,128,0,0,0
- .size c
lib_calljmp,.-.L.clib_calljmp
+ .size c
decl(clib_calljmp),.-.L.cdecl(clib_calljmp)
#elif defined(__powerpc__)
#elif defined(__powerpc__)
@@
-344,10
+357,10
@@
_ (26, 6) _ (27, 7) _ (28, 8) _ (29, 9) _ (30, 10) _ (31, 11)
#define CLIB_POWERPC_ALTIVEC_N_REGS 0
#endif
#define CLIB_POWERPC_ALTIVEC_N_REGS 0
#endif
- .global c
lib_setjmp
+ .global c
decl(clib_setjmp)
.align 4
.align 4
- .type c
lib_setjmp
, @function
-c
lib_setjmp
:
+ .type c
decl(clib_setjmp)
, @function
+c
decl(clib_setjmp)
:
mflr 0
stw 0, 4*0(3)
stw 1, 4*1(3)
mflr 0
stw 0, 4*0(3)
stw 1, 4*1(3)
@@
-380,10
+393,10
@@
clib_setjmp:
blr
blr
- .global c
lib_longjmp
+ .global c
decl(clib_longjmp)
.align 4
.align 4
- .type c
lib_longjmp
, @function
-c
lib_longjmp:
+ .type c
decl(clib_longjmp)
, @function
+c
decl(clib_longjmp):
lwz 0, 4*0(3)
mtlr 0
lwz 0, 4*0(3)
mtlr 0
@@
-417,10
+430,10
@@
clib_longjmp:
blr
blr
- .global c
lib_calljmp
+ .global c
decl(clib_calljmp)
.align 4
.align 4
- .type c
lib_calljmp
, @function
-c
lib_calljmp:
+ .type c
decl(clib_calljmp)
, @function
+c
decl(clib_calljmp):
/* Make sure stack is 16 byte aligned. */
andi. 0, 5, 0xf
sub 5, 5, 0
/* Make sure stack is 16 byte aligned. */
andi. 0, 5, 0xf
sub 5, 5, 0
@@
-458,10
+471,10
@@
clib_calljmp:
#elif defined(__arm__)
#elif defined(__arm__)
- .global c
lib_setjmp
+ .global c
decl(clib_setjmp)
.align 4
.align 4
- .type c
lib_setjmp
, %function
-c
lib_setjmp
:
+ .type c
decl(clib_setjmp)
, %function
+c
decl(clib_setjmp)
:
mov ip, r0 /* jmp buffer */
/* Save integer registers */
mov ip, r0 /* jmp buffer */
/* Save integer registers */
@@
-481,10
+494,10
@@
clib_setjmp:
mov r0, r1
bx lr
mov r0, r1
bx lr
- .global c
lib_longjmp
+ .global c
decl(clib_longjmp)
.align 4
.align 4
- .type c
lib_longjmp
, %function
-c
lib_longjmp:
+ .type c
decl(clib_longjmp)
, %function
+c
decl(clib_longjmp):
mov ip, r0 /* jmp buffer */
/* Restore integer registers. */
mov ip, r0 /* jmp buffer */
/* Restore integer registers. */
@@
-504,10
+517,10
@@
clib_longjmp:
mov r0, r1
bx lr
mov r0, r1
bx lr
- .global c
lib_calljmp
+ .global c
decl(clib_calljmp)
.align 4
.align 4
- .type c
lib_calljmp
, %function
-c
lib_calljmp:
+ .type c
decl(clib_calljmp)
, %function
+c
decl(clib_calljmp):
/* Make sure stack is 8 byte aligned. */
bic r2, r2, #7
/* Make sure stack is 8 byte aligned. */
bic r2, r2, #7
@@
-541,51
+554,51
@@
clib_calljmp:
#elif defined(__xtensa__)
/* FIXME implement if needed. */
#elif defined(__xtensa__)
/* FIXME implement if needed. */
- .global c
lib_setjmp
+ .global c
decl(clib_setjmp)
.align 4
.align 4
- .type c
lib_setjmp
, %function
-c
lib_setjmp
:
+ .type c
decl(clib_setjmp)
, %function
+c
decl(clib_setjmp)
:
1: j 1b
1: j 1b
- .global c
lib_longjmp
+ .global c
decl(clib_longjmp)
.align 4
.align 4
- .type c
lib_longjmp
, @function
-c
lib_longjmp:
+ .type c
decl(clib_longjmp)
, @function
+c
decl(clib_longjmp):
1: j 1b
1: j 1b
- .global c
lib_calljmp
+ .global c
decl(clib_calljmp)
.align 4
.align 4
- .type c
lib_calljmp
, %function
-c
lib_calljmp:
+ .type c
decl(clib_calljmp)
, %function
+c
decl(clib_calljmp):
1: j 1b
#elif defined(__TMS320C6X__)
/* FIXME implement if needed. */
1: j 1b
#elif defined(__TMS320C6X__)
/* FIXME implement if needed. */
- .global c
lib_setjmp
+ .global c
decl(clib_setjmp)
.align 4
.align 4
- .type c
lib_setjmp
, %function
-c
lib_setjmp
:
+ .type c
decl(clib_setjmp)
, %function
+c
decl(clib_setjmp)
:
1: B .S1 1b
1: B .S1 1b
- .global c
lib_longjmp
+ .global c
decl(clib_longjmp)
.align 4
.align 4
- .type c
lib_longjmp
, @function
-c
lib_longjmp:
+ .type c
decl(clib_longjmp)
, @function
+c
decl(clib_longjmp):
1: B .S1 1b
1: B .S1 1b
- .global c
lib_calljmp
+ .global c
decl(clib_calljmp)
.align 4
.align 4
- .type c
lib_calljmp
, %function
-c
lib_calljmp:
+ .type c
decl(clib_calljmp)
, %function
+c
decl(clib_calljmp):
1: B .S1 1b
#elif defined(_mips) && __mips == 64
1: B .S1 1b
#elif defined(_mips) && __mips == 64
- .global c
lib_setjmp
+ .global c
decl(clib_setjmp)
.align 8
.align 8
- .type c
lib_setjmp
, %function
-c
lib_setjmp
:
+ .type c
decl(clib_setjmp)
, %function
+c
decl(clib_setjmp)
:
sd $ra, 0($a0)
sd $sp, 8($a0)
sd $gp, 16($a0)
sd $ra, 0($a0)
sd $sp, 8($a0)
sd $gp, 16($a0)
@@
-602,10
+615,10
@@
clib_setjmp:
jr $ra
nop
jr $ra
nop
- .global c
lib_longjmp
+ .global c
decl(clib_longjmp)
.align 8
.align 8
- .type c
lib_longjmp
, @function
-c
lib_longjmp
:
+ .type c
decl(clib_longjmp)
, @function
+c
decl(clib_longjmp)
:
move $v0, $a1
bne $v0, $0, 1f
nop
move $v0, $a1
bne $v0, $0, 1f
nop
@@
-626,10
+639,10
@@
clib_longjmp:
jr $ra
nop
jr $ra
nop
- .global c
lib_calljmp
+ .global c
decl(clib_calljmp)
.align 8
.align 8
- .type c
lib_calljmp
, %function
-c
lib_calljmp
:
+ .type c
decl(clib_calljmp)
, %function
+c
decl(clib_calljmp)
:
/* Force 16 byte alignment of the new stack */
li $t1, -16
and $t0, $a2, $t1
/* Force 16 byte alignment of the new stack */
li $t1, -16
and $t0, $a2, $t1
@@
-693,10
+706,10
@@
clib_calljmp:
REG_PAIR (d10, d11, 128); \
REG_PAIR (d12, d13, 144); \
REG_PAIR (d14, d15, 160);
REG_PAIR (d10, d11, 128); \
REG_PAIR (d12, d13, 144); \
REG_PAIR (d14, d15, 160);
-// int c
lib_setjmp
(jmp_buf)
- .global c
lib_setjmp
- .type c
lib_setjmp
, %function
-c
lib_setjmp
:
+// int c
decl(clib_setjmp)
(jmp_buf)
+ .global c
decl(clib_setjmp)
+ .type c
decl(clib_setjmp)
, %function
+c
decl(clib_setjmp)
:
mov x16, sp
#define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]
mov x16, sp
#define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]
@@
-706,11
+719,11
@@
clib_setjmp:
#undef REG_ONE
mov x0, x1
ret
#undef REG_ONE
mov x0, x1
ret
- .size c
lib_setjmp, .-clib_setjmp
-// void c
lib_longjmp
(jmp_buf, int) __attribute__ ((noreturn))
- .global c
lib_longjmp
- .type c
lib_longjmp
, %function
-c
lib_longjmp
:
+ .size c
decl(clib_setjmp), .-cdecl(clib_setjmp)
+// void c
decl(clib_longjmp)
(jmp_buf, int) __attribute__ ((noreturn))
+ .global c
decl(clib_longjmp)
+ .type c
decl(clib_longjmp)
, %function
+c
decl(clib_longjmp)
:
#define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]
GPR_LAYOUT
#define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]
GPR_LAYOUT
@@
-723,13
+736,13
@@
clib_longjmp:
// cinc w0, w1, eq
// use br not ret, as ret is guaranteed to mispredict
br x30
// cinc w0, w1, eq
// use br not ret, as ret is guaranteed to mispredict
br x30
- .size c
lib_longjmp, .-clib_longjmp
+ .size c
decl(clib_longjmp), .-cdecl(clib_longjmp)
-// void c
lib_calljmp
(x0=function, x1=arg, x2=new_stack)
- .global c
lib_calljmp
- .type c
lib_calljmp
, %function
-c
lib_calljmp
:
+// void c
decl(clib_calljmp)
(x0=function, x1=arg, x2=new_stack)
+ .global c
decl(clib_calljmp)
+ .type c
decl(clib_calljmp)
, %function
+c
decl(clib_calljmp)
:
// save fn ptr
mov x3, x0
// set up fn arg
// save fn ptr
mov x3, x0
// set up fn arg
@@
-756,9
+769,11
@@
clib_calljmp:
ldr x30,[x4, #8]
mov sp, x3
ret
ldr x30,[x4, #8]
mov sp, x3
ret
- .size c
lib_calljmp, .-clib_calljmp
+ .size c
decl(clib_calljmp), .-cdecl(clib_calljmp)
#else
#error "unknown machine"
#endif
#else
#error "unknown machine"
#endif
+#ifndef __APPLE__
.section .note.GNU-stack,"",%progbits
.section .note.GNU-stack,"",%progbits
+#endif