author | Elliott Hughes <enh@google.com> | |
Tue, 9 Dec 2014 00:16:19 +0000 (00:16 +0000) | ||
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | |
Tue, 9 Dec 2014 00:16:20 +0000 (00:16 +0000) |
libc/arch-arm/bionic/setjmp.S | patch | blob | history | |
libc/arch-arm64/bionic/setjmp.S | patch | blob | history |
index 7a99fc065ce8f7806d8b7c0ab7de76415c603fa1..8d7786c12e18f7a6155722a11f99d6b3eb2aaef5 100644 (file)
// FP registers will be loaded/stored with instructions
// that expect 8-byte alignment.
-#define _JB_MAGIC 0
-#define _JB_SIGMASK (_JB_MAGIC+1)
+#define _JB_SIGFLAG 0
+#define _JB_SIGMASK (_JB_SIGFLAG+1)
#define _JB_FLOAT_BASE (_JB_SIGMASK+1)
#define _JB_FLOAT_STATE (_JB_FLOAT_BASE + (15-8+1)*2)
#define _JB_CORE_BASE (_JB_FLOAT_STATE+1)
-.L_setjmp_magic_signal_mask_n: .word 0x4278f500
-.L_setjmp_magic_signal_mask_y: .word 0x4278f501
-
ENTRY(setjmp)
mov r1, #1
b sigsetjmp
// int sigsetjmp(sigjmp_buf env, int save_signal_mask);
ENTRY(sigsetjmp)
+ // Record whether or not we're saving the signal mask.
+ str r1, [r0, #(_JB_SIGFLAG * 4)]
+
// Do we need to save the signal mask?
teq r1, #0
- ldreq r1, .L_setjmp_magic_signal_mask_n
beq 1f
// Get current signal mask.
ldmfd sp!, {r0, r14}
.cfi_def_cfa_offset 0
- // Save signal mask.
+ // Save the signal mask.
str r1, [r0, #(_JB_SIGMASK * 4)]
- ldr r1, .L_setjmp_magic_signal_mask_y
-
1:
- // Save magic number.
- str r1, [r0, #(_JB_MAGIC * 4)]
-
// Save core registers.
add r1, r0, #(_JB_CORE_BASE * 4)
stmia r1, {r4-r14}
// void siglongjmp(sigjmp_buf env, int value);
ENTRY(siglongjmp)
- // Check magic.
- ldr r3, [r0, #(_JB_MAGIC * 4)]
- ldr r2, .L_setjmp_magic_signal_mask_n
- teq r2, r3
+ // Do we need to restore the signal mask?
+ ldr r2, [r0, #(_JB_SIGFLAG * 4)]
+ teq r2, #0
beq 1f
- ldr r2, .L_setjmp_magic_signal_mask_y
- teq r2, r3
- bne longjmperror
- // Restore signal mask.
+ // Restore the signal mask.
stmfd sp!, {r0, r1, r14}
.cfi_def_cfa_offset 12
.cfi_rel_offset r0, 0
index d8b98a33c66970d7c695488ba46258ed116f8ad8..d1747e43586543921af62eec433e3b413c9274f8 100644 (file)
//
// word name description
// -------------------------------------------------------------------------
-// 0-1 sigmask signal mask (not used with _setjmp / _longjmp)
-// 2 core_base base of core registers (x19-x30, sp)
-// 28 float_base base of float registers (d8-d15)
-// 44 magic magic number
-// 45- reserved reserved entries (room to grow)
+// 0 sigflag 0 => signal mask not valid
+// 1 unused unused (for alignment)
+// 2-3 sigmask signal mask (not used with _setjmp / _longjmp)
+// 4 core_base base of core registers (x19-x30, sp)
+// 30 float_base base of float registers (d8-d15)
+// 46- reserved reserved entries (room to grow)
// 64
//
// NOTE: The instructions that load/store core/vfp registers expect 8-byte
// need to save status/control registers for VFP (it is not a
// requirement for setjmp).
-#define _JB_SIGMASK 0
+#define _JB_SIGFLAG 0
+#define _JB_SIGMASK (_JB_SIGFLAG + 2)
#define _JB_CORE_BASE (_JB_SIGMASK + 2)
#define _JB_FLOAT_BASE (_JB_CORE_BASE + (31-19+1)*2)
-#define _JB_MAGIC (_JB_FLOAT_BASE + 16*2)
-
-.L_setjmp_magic_signal_mask_n: .word 0x53657200
-.L_setjmp_magic_signal_mask_y: .word 0x53657201
ENTRY(setjmp)
mov w1, #1
// int sigsetjmp(sigjmp_buf env, int save_signal_mask);
ENTRY(sigsetjmp)
+ // Record whether or not we're saving the signal mask.
+ str w1, [x0, #(_JB_SIGFLAG * 4)]
+
// Do we need to save the signal mask?
- ldr w9, .L_setjmp_magic_signal_mask_n
cbz w1, 1f
// Save current signal mask.
bl sigprocmask
ldp x0, x30, [sp], #16
- ldr w9, .L_setjmp_magic_signal_mask_y
-
1:
- // Save magic number.
- str w9, [x0, #(_JB_MAGIC * 4)]
-
// Save core registers.
mov x10, sp
stp x30, x10, [x0, #(_JB_CORE_BASE * 4 + 16 * 0)]
stp d10, d11, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 2)]
stp d8, d9, [x0, #(_JB_FLOAT_BASE * 4 + 16 * 3)]
- mov w0, wzr
+ mov w0, #0
ret
END(sigsetjmp)
// void siglongjmp(sigjmp_buf env, int value);
ENTRY(siglongjmp)
- // Check magic.
- ldr w10, [x0, #(_JB_MAGIC * 4)]
- ldr w9, .L_setjmp_magic_signal_mask_n
- cmp w9, w10
- b.eq 1f
- ldr w9, .L_setjmp_magic_signal_mask_y
- cmp w9, w10
- b.ne longjmperror
+ // Do we need to restore the signal mask?
+ ldr w9, [x0, #(_JB_SIGFLAG * 4)]
+ cbz w9, 1f
// Restore signal mask.
stp x0, x30, [sp, #-16]!