]> git.saurik.com Git - apple/libc.git/blobdiff - x86_64/sys/_setjmp.s
Libc-763.11.tar.gz
[apple/libc.git] / x86_64 / sys / _setjmp.s
index 7ebf81c6b34695981e05f53ef3a7844ffcf73f40..02cd31ebf5643007408211e3e1a564b4cee308e6 100644 (file)
@@ -70,15 +70,9 @@ LEAF(__setjmp, 0)
        movq    (%rsp), %rax
        movq    %rax, JB_RIP(%rdi)
        // RSP is set to the frame return address plus 8
-       movq    %rsp, %rax
-       addq    $8, %rax
+       leaq    8(%rsp), %rax
        movq    %rax, JB_RSP(%rdi)
 
-       // save rflags - you can't use movq
-       pushfq
-       popq    %rax
-       movq    %rax, JB_RFLAGS(%rdi)
-
        // save fp control word
        fnstcw  JB_FPCONTROL(%rdi)
 
@@ -86,19 +80,18 @@ LEAF(__setjmp, 0)
        stmxcsr JB_MXCSR(%rdi)
 
        // return 0
-       xorq    %rax, %rax
+       xorl    %eax, %eax
        ret
 
 
 LEAF(__longjmp, 0)
-       fninit                  // reset FP coprocessor
-
+       fninit                          // Clear all FP exceptions
        // %rdi is a jmp_buf (struct sigcontext *)
-       // %rsi is the return value
-       movq    %rsi, %rax
-       testq   %rax, %rax
+       // %esi is the return value
+       movl    %esi, %eax
+       testl   %esi, %esi
        jnz     1f
-       addq    $1, %rax
+       incl    %eax
 
        // general registers
 1:
@@ -116,8 +109,8 @@ LEAF(__longjmp, 0)
        // restore MXCSR
        ldmxcsr JB_MXCSR(%rdi)
 
-       // rflags
-       pushq   JB_RFLAGS(%rdi)
-       popfq
+
+       // Make sure DF is reset
+       cld
 
        jmp             *JB_RIP(%rdi)