*
* @APPLE_LICENSE_HEADER_START@
*
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <architecture/i386/asm_help.h>
-#define JB_ONSTACK 0
+// The FP control word is actually two bytes, but there's no harm in
+// using four bytes for it and keeping the struct aligned.
+#define JB_FPCW 0
#define JB_MASK 4
-#define JB_EAX 8
+#define JB_MXCSR 8
#define JB_EBX 12
#define JB_ECX 16
#define JB_EDX 20
#define JB_FS 64
#define JB_GS 68
+#define SAVE_SEG_REGS 1
LEAF(__setjmp, 0)
movl 4(%esp), %ecx // jmp_buf (struct sigcontext *)
- // now build sigcontext
+ // Build the jmp_buf
+ fnstcw JB_FPCW(%ecx) // Save the FP control word
+ stmxcsr JB_MXCSR(%ecx) // Save the MXCSR
movl %ebx, JB_EBX(%ecx)
movl %edi, JB_EDI(%ecx)
movl %esi, JB_ESI(%ecx)
LEAF(__longjmp, 0)
- subl $2,%esp
- fnstcw (%esp) // save FP control word
fninit // reset FP coprocessor
- fldcw (%esp) // restore FP control word
- addl $2,%esp
- movl 4(%esp), %ecx // jmp_buf (struct sigcontext *)
+ movl 4(%esp), %ecx // jmp_buf (struct sigcontext *)
movl 8(%esp), %eax // return value
testl %eax, %eax
jnz 1f
movl JB_EDI(%ecx), %edi
movl JB_EBP(%ecx), %ebp
movl JB_ESP(%ecx), %esp
+ fldcw JB_FPCW(%ecx) // Restore FP control word
+ ldmxcsr JB_MXCSR(%ecx) // Restore the MXCSR
#if SAVE_SEG_REGS
// segment registers
mov JB_SS(%ecx), %ss
- mov JB_CS(%ecx), %cs
+ // mov JB_CS(%ecx), %cs // can't set cs?
mov JB_DS(%ecx), %ds
mov JB_ES(%ecx), %es
mov JB_FS(%ecx), %fs