summaryrefslogtreecommitdiff
path: root/libs/pbd/fpu.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-04-21 11:39:19 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-04-21 11:39:31 -0400
commita5d7e8446bdc488be9d52cede7f49ad9910cc127 (patch)
treeab50fcaa8dd8009ef892ac9a27505b3facbe49e3 /libs/pbd/fpu.cc
parent63b39677241a6dc07c1426554b6e2da6d9712d94 (diff)
merge all mingw and msvc specific code for FPU information into libs/pbd/fpu.cc and remove msvc-specific version
Diffstat (limited to 'libs/pbd/fpu.cc')
-rw-r--r--libs/pbd/fpu.cc35
1 files changed, 28 insertions, 7 deletions
diff --git a/libs/pbd/fpu.cc b/libs/pbd/fpu.cc
index 0998f43bdc..c297d2dd07 100644
--- a/libs/pbd/fpu.cc
+++ b/libs/pbd/fpu.cc
@@ -16,7 +16,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#if !(defined (COMPILER_MSVC) || defined (COMPILER_MINGW))
+
#include "libpbd-config.h"
#define _XOPEN_SOURCE 600
@@ -43,7 +43,24 @@ FPU::FPU ()
return;
#else
-#ifndef _LP64 //USE_X86_64_ASM
+#ifdef PLATFORM_WINDOWS
+
+#ifndef USE_X86_64_ASM
+ /* no 32 bit version of assembler for windows */
+ return;
+#else
+ // Get CPU flags using Microsoft function
+ // It works for both 64 and 32 bit systems
+ // no need to use assembler for getting info from register, this function does this for us
+ int cpuInfo[4];
+ __cpuid (cpuInfo, 1);
+ cpuflags = cpuInfo[3];
+#endif
+
+#else
+
+#ifndef USE_X86_64_ASM /* *nix; 32 bit version */
+
asm volatile (
"mov $1, %%eax\n"
"pushl %%ebx\n"
@@ -55,7 +72,7 @@ FPU::FPU ()
: "%eax", "%ecx", "%edx"
);
-#else
+#else /* *nix; 64 bit version */
/* asm notes: although we explicitly save&restore rbx, we must tell
gcc that ebx,rbx is clobbered so that it doesn't try to use it as an intermediate
@@ -75,6 +92,7 @@ FPU::FPU ()
);
#endif /* USE_X86_64_ASM */
+#endif /* PLATFORM_WINDOWS */
if (cpuflags & (1<<25)) {
_flags = Flags (_flags | (HasSSE|HasFlushToZero));
@@ -112,12 +130,19 @@ FPU::FPU ()
memset (*fxbuf, 0, 512);
+#ifdef COMPILER_MSVC
+ __asm {
+ mov eax, fxbuf
+ fxsave [eax]
+ };
+#else
asm volatile (
"fxsave (%0)"
:
: "r" (*fxbuf)
: "memory"
);
+#endif
uint32_t mxcsr_mask = *((uint32_t*) &((*fxbuf)[28]));
@@ -140,7 +165,3 @@ FPU::FPU ()
FPU::~FPU ()
{
}
-
-#else // COMPILER_MSVC
- const char* pbd_fpu = "pbd/msvc/fpu.cc takes precedence over this file";
-#endif // COMPILER_MSVC