From 2ed1c2ae2b8368582b63d71479b1bc3006dd3dc1 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Thu, 6 Feb 2014 17:03:15 -0800 Subject: [PATCH] - attempt to see if this win64 asm is more reliable for streflop --- source/shared_lib/include/streflop/FPUSettings.h | 12 ++++++------ source/shared_lib/sources/streflop/FPUSettings.asm | 13 +++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/source/shared_lib/include/streflop/FPUSettings.h b/source/shared_lib/include/streflop/FPUSettings.h index 64fa35c7..514b577a 100644 --- a/source/shared_lib/include/streflop/FPUSettings.h +++ b/source/shared_lib/include/streflop/FPUSettings.h @@ -137,14 +137,14 @@ enum FPU_RoundMode { #if _WIN64 /* No fldcw intrinsics on Windows x64, punt to external asm */ -extern "C" { void streflop_winx64_fldcw(unsigned int mode); } -extern "C" { unsigned int streflop_winx64_fstcw(); } +extern "C" { void streflop_winx64_fldcw(short mode); } +extern "C" { short streflop_winx64_fstcw(); } extern "C" { void streflop_winx64_fclex(void); } -extern "C" { void streflop_winx64_stmxcsr(unsigned int mode); } -extern "C" { void streflop_winx64_ldmxcsr(unsigned int mode); } +extern "C" { void streflop_winx64_stmxcsr(int mode); } +extern "C" { void streflop_winx64_ldmxcsr(int mode); } -#define STREFLOP_FSTCW(cw) do { int tmp = 0; tmp = streflop_winx64_fstcw(); (cw) = tmp; } while (0) -#define STREFLOP_FLDCW(cw) do { int tmp = (cw); streflop_winx64_fldcw(tmp); } while (0) +#define STREFLOP_FSTCW(cw) do { short tmp = 0; tmp = streflop_winx64_fstcw(); (cw) = tmp; } while (0) +#define STREFLOP_FLDCW(cw) do { short tmp = (cw); streflop_winx64_fldcw(tmp); } while (0) #define STREFLOP_STMXCSR(cw) do { int tmp = 0; streflop_winx64_stmxcsr(tmp); (cw) = tmp; } while (0) #define STREFLOP_LDMXCSR(cw) do { int tmp = (cw); streflop_winx64_ldmxcsr(tmp); } while (0) diff --git a/source/shared_lib/sources/streflop/FPUSettings.asm b/source/shared_lib/sources/streflop/FPUSettings.asm index 45355c19..1b3d692d 100644 --- a/source/shared_lib/sources/streflop/FPUSettings.asm +++ b/source/shared_lib/sources/streflop/FPUSettings.asm @@ -8,7 +8,6 @@ ; be found in the AUTHORS file in the root of the source tree. ; - _text SEGMENT ; %ifidn __OUTPUT_FORMAT__,x64 ; %ifdef _WIN64 @@ -23,9 +22,15 @@ streflop_winx64_fclex ENDP streflop_winx64_fldcw PROC FRAME fclex - mov qword ptr [rsp + 8], rcx - .ENDPROLOG - fldcw [rsp + 8] +; mov qword ptr [rsp + 8], rcx +; .ENDPROLOG +; fldcw [rsp + 8] +; ret + sub rsp, 8 + mov [rsp], rcx ; win x64 specific + .ENDPROLOG + fldcw [rsp] + add rsp, 8 ret streflop_winx64_fldcw ENDP