$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r78155 - trunk/libs/context/src/asm
From: oliver.kowalke_at_[hidden]
Date: 2012-04-23 07:48:48
Author: olli
Date: 2012-04-23 07:48:47 EDT (Mon, 23 Apr 2012)
New Revision: 78155
URL: http://svn.boost.org/trac/boost/changeset/78155
Log:
context: fpu enve preserving in i386 too
Text files modified: 
   trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm   |    32 ++++++++++++++++++--------------        
   trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S   |    38 ++++++++++++++++++++------------------  
   trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S |    38 ++++++++++++++++++++------------------  
   3 files changed, 58 insertions(+), 50 deletions(-)
Modified: trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm	(original)
+++ trunk/libs/context/src/asm/fcontext_i386_ms_pe_masm.asm	2012-04-23 07:48:47 EDT (Mon, 23 Apr 2012)
@@ -72,15 +72,22 @@
     mov     eax,         [esp]      ; load return address
     mov     [ecx+014h],  eax        ; save return address
 
-;    stmxcsr [ecx+028h]              ; save MMX control word
-;    fnstcw  [ecx+02ch]              ; save x87 control word
-
-    mov     ecx,        [esp+08h]   ; load address of the second fcontext_t arg
-    mov     edi,        [ecx]       ; restore EDI
-    mov     esi,        [ecx+04h]   ; restore ESI
-    mov     ebx,        [ecx+08h]   ; restore EBX
-    mov     ebp,        [ecx+0ch]   ; restore EBP
-
+    mov     edx,        [esp+08h]   ; load address of the second fcontext_t arg
+    mov     edi,        [edx]       ; restore EDI
+    mov     esi,        [edx+04h]   ; restore ESI
+    mov     ebx,        [edx+08h]   ; restore EBX
+    mov     ebp,        [edx+0ch]   ; restore EBP
+
+    movl    eax,        [esp+010h]  ; check if fpu enve preserving was requested
+    cmp     0,          eax 
+    je      1f
+
+    stmxcsr [ecx+028h]              ; save MMX control word
+    fnstcw  [ecx+02ch]              ; save x87 control word
+    ldmxcsr [edx+028h]              ; restore MMX control word
+    fldcw   [edx+02ch]              ; restore x87 control word
+1:
+    mov     ecx,        edx
     assume  fs:nothing
     mov     edx,        fs:[018h]   ; load NT_TIB
     assume  fs:error
@@ -93,9 +100,6 @@
     mov     eax,        [ecx+024h]  ; load fiber local storage
     mov     [edx+010h], eax         ; restore fiber local storage
 
-;    ldmxcsr [ecx+028h]              ; restore MMX control word
-;    fldcw   [ecx+02ch]              ; restore x87 control word
-
     mov     eax,        [esp+0ch]   ; use third arg as return value after jump
 
     mov     esp,        [ecx+010h]  ; restore ESP
@@ -129,8 +133,8 @@
     lea  ecx,         [edx+08h]     ; load address of next SEH item
     mov  [eax+02ch],  ecx           ; save next SEH
 
-;    stmxcsr [eax+028h]              ; save MMX control word
-;    fnstcw  [eax+02ch]              ; save x87 control word
+    stmxcsr [eax+028h]              ; save MMX control word
+    fnstcw  [eax+02ch]              ; save x87 control word
 
     mov  ecx,         finish        ; address of finish
     mov  [edx],       ecx
Modified: trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_i386_sysv_elf_gas.S	2012-04-23 07:48:47 EDT (Mon, 23 Apr 2012)
@@ -42,31 +42,33 @@
     movl    %ebx,       0x8(%ecx)   /* save EBX */
     movl    %ebp,       0xc(%ecx)   /* save EBP */
 
-/*    stmxcsr  0x20(%ecx)  */            /* save MMX control and status word */
-/*    fnstcw   0x24(%ecx)  */            /* save x87 control word */
-
     leal    0x4(%esp),  %eax        /* exclude the return address */
     movl    %eax,       0x10(%ecx)  /* save as stack pointer */
     movl    (%esp),     %eax        /* load return address */
     movl    %eax,       0x14(%ecx)  /* save return address */
 
-
-    movl    0x8(%esp),   %ecx       /* load address of the second fcontext_t arg */
-    movl    (%ecx),      %edi       /* restore EDI */
-    movl    0x4(%ecx),   %esi       /* restore ESI */
-    movl    0x8(%ecx),   %ebx       /* restore EBX */
-    movl    0xc(%ecx),   %ebp       /* restore EBP */
-
-/*    ldmxcsr  0x20(%ecx)  */           /* restore MMX control and status word */
-/*    fldcw    0x24(%ecx)  */           /* restore x87 control word */
-
+    movl    0x8(%esp),   %edx       /* load address of the second fcontext_t arg */
+    movl    (%edx),      %edi       /* restore EDI */
+    movl    0x4(%edx),   %esi       /* restore ESI */
+    movl    0x8(%edx),   %ebx       /* restore EBX */
+    movl    0xc(%edx),   %ebp       /* restore EBP */
+
+    movl    0x10(%esp),  %eax       /* check if fpu enve preserving was requested */
+    cmp     $0,          %eax
+    je      1f
+
+    stmxcsr  0x20(%ecx)             /* save MMX control and status word */
+    fnstcw   0x24(%ecx)             /* save x87 control word */
+    ldmxcsr  0x20(%edx)             /* restore MMX control and status word */
+    fldcw    0x24(%edx)             /* restore x87 control word */
+1:
     movl    0xc(%esp),   %eax       /* use third arg as return value after jump */
 
-    movl    0x10(%ecx),  %esp       /* restore ESP */
+    movl    0x10(%edx),  %esp       /* restore ESP */
     movl    %eax,        0x4(%esp)  /* use third arg as first arg in context function */
-    movl    0x14(%ecx),  %ecx       /* fetch the address to return to */
+    movl    0x14(%edx),  %edx       /* fetch the address to return to */
 
-    jmp     *%ecx                   /* indirect jump to context */
+    jmp     *%edx                   /* indirect jump to context */
 .size jump_fcontext,.-jump_fcontext
 
 .text
@@ -95,8 +97,8 @@
     leal   -0x14(%edx),    %edx         /* reserve space for the last frame on stack, (ESP + 4) % 16 == 0 */
     movl   %edx,           0x10(%eax)   /* save the aligned stack base */
 
-;    stmxcsr  0x20(%eax)                 /* save MMX control and status word */
-;    fnstcw   0x24(%eax)                 /* save x87 control word */
+    stmxcsr  0x20(%eax)                 /* save MMX control and status word */
+    fnstcw   0x24(%eax)                 /* save x87 control word */
 
     call    2f
 2:  popl    %ecx                        /* address of label 2 */
Modified: trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S
==============================================================================
--- trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S	(original)
+++ trunk/libs/context/src/asm/fcontext_i386_sysv_macho_gas.S	2012-04-23 07:48:47 EDT (Mon, 23 Apr 2012)
@@ -41,31 +41,33 @@
     movl    %ebx,       0x8(%ecx)   /* save EBX */
     movl    %ebp,       0xc(%ecx)   /* save EBP */
 
-/*    stmxcsr  0x20(%ecx)  */            /* save MMX control and status word */
-/*    fnstcw   0x24(%ecx)  */            /* save x87 control word */
-
     leal    0x4(%esp),  %eax        /* exclude the return address */
     movl    %eax,       0x10(%ecx)  /* save as stack pointer */
     movl    (%esp),     %eax        /* load return address */
     movl    %eax,       0x14(%ecx)  /* save return address */
 
-
-    movl    0x8(%esp),   %ecx       /* load address of the second fcontext_t arg */
-    movl    (%ecx),      %edi       /* restore EDI */
-    movl    0x4(%ecx),   %esi       /* restore ESI */
-    movl    0x8(%ecx),   %ebx       /* restore EBX */
-    movl    0xc(%ecx),   %ebp       /* restore EBP */
-
-/*    ldmxcsr  0x20(%ecx)  */           /* restore MMX control and status word */
-/*    fldcw    0x24(%ecx)  */           /* restore x87 control word */
-
+    movl    0x8(%esp),   %edx       /* load address of the second fcontext_t arg */
+    movl    (%edx),      %edi       /* restore EDI */
+    movl    0x4(%edx),   %esi       /* restore ESI */
+    movl    0x8(%edx),   %ebx       /* restore EBX */
+    movl    0xc(%edx),   %ebp       /* restore EBP */
+
+    movl    0x10(%esp),  %eax       /* check if fpu enve preserving was requested */
+    cmp     $0,          %eax
+    je      1f
+
+    stmxcsr  0x20(%ecx)             /* save MMX control and status word */
+    fnstcw   0x24(%ecx)             /* save x87 control word */
+    ldmxcsr  0x20(%edx)             /* restore MMX control and status word */
+    fldcw    0x24(%edx)             /* restore x87 control word */
+1:
     movl    0xc(%esp),   %eax       /* use third arg as return value after jump */
 
-    movl    0x10(%ecx),  %esp       /* restore ESP */
+    movl    0x10(%edx),  %esp       /* restore ESP */
     movl    %eax,        0x4(%esp)  /* use third arg as first arg in context function */
-    movl    0x14(%ecx),  %ecx       /* fetch the address to return to */
+    movl    0x14(%edx),  %edx       /* fetch the address to return to */
 
-    jmp     *%ecx                   /* indirect jump to context */
+    jmp     *%edx                   /* indirect jump to context */
 
 .text
 .globl _make_fcontext
@@ -92,8 +94,8 @@
     leal   -0x14(%edx),    %edx         /* reserve space for the last frame on stack, (ESP + 4) % 16 == 0 */
     movl   %edx,           0x10(%eax)   /* save the aligned stack base */
 
-;    stmxcsr  0x20(%eax)                 /* save MMX control and status word */
-;    fnstcw   0x24(%eax)                 /* save x87 control word */
+    stmxcsr  0x20(%eax)                 /* save MMX control and status word */
+    fnstcw   0x24(%eax)                 /* save x87 control word */
 
     call    2f
 2:  popl    %ecx                        /* address of label 2 */