From 6cb742c289cd27b987b645d529b10ae07b28bbe3 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 24 Apr 2015 02:43:52 +0200 Subject: [PATCH] windows 32bit asm/fpu support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This still leaves cache_aligned_malloc() in libs/pbd/malign.cc pending _aligned_free (windows crashes when using free() on memory allocated with _aligned_malloc()). So far however there seems to be no issue with default malloc for audio+midi buffers on win32… --- libs/pbd/fpu.cc | 22 +++++++++++++++------- libs/pbd/wscript | 4 ---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libs/pbd/fpu.cc b/libs/pbd/fpu.cc index ad80e0c93c..76de065d28 100644 --- a/libs/pbd/fpu.cc +++ b/libs/pbd/fpu.cc @@ -49,17 +49,12 @@ FPU::FPU () #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 @@ -98,7 +93,7 @@ FPU::FPU () : "%rax", "%rbx", "%rcx", "%rdx" ); -#endif /* USE_X86_64_ASM */ +#endif /* _LP64 */ #endif /* PLATFORM_WINDOWS */ if (cpuflags & (1<<25)) { @@ -122,12 +117,20 @@ FPU::FPU () 31 for the MXCSR_MASK value. If bit 6 is set, DAZ is supported, otherwise, it isn't. */ - + #ifndef HAVE_POSIX_MEMALIGN +# ifdef PLATFORM_WINDOWS + fxbuf = (char **) _aligned_malloc (sizeof (char *), 16); + assert (fxbuf); + *fxbuf = (char *) _aligned_malloc (512, 16); + assert (*fxbuf); +# else +# warning using default malloc for aligned memory fxbuf = (char **) malloc (sizeof (char *)); assert (fxbuf); *fxbuf = (char *) malloc (512); assert (*fxbuf); +# endif #else (void) posix_memalign ((void **) &fxbuf, 16, sizeof (char *)); assert (fxbuf); @@ -163,8 +166,13 @@ FPU::FPU () _flags = Flags (_flags | HasDenormalsAreZero); } +#if !defined HAVE_POSIX_MEMALIGN && defined PLATFORM_WINDOWS + _aligned_free (*fxbuf); + _aligned_free (fxbuf); +#else free (*fxbuf); free (fxbuf); +#endif } #endif } diff --git a/libs/pbd/wscript b/libs/pbd/wscript index a9ac3d5f63..8f947fbb26 100644 --- a/libs/pbd/wscript +++ b/libs/pbd/wscript @@ -4,7 +4,6 @@ from waflib import Options from waflib import TaskGen import os import sys -import re # Version of this package (even if built as a child) MAJOR = '4' @@ -146,9 +145,6 @@ def build(bld): if bld.env['build_target'] == 'x86_64': obj.defines += [ 'USE_X86_64_ASM' ] if bld.env['build_target'] == 'mingw': - if re.search ('/^x86_64/', str(bld.env['CC'])): - obj.defines += [ 'USE_X86_64_ASM' ] - obj.defines += ['NO_POSIX_MEMALIGN' ] obj.source += [ 'windows_special_dirs.cc' ] obj.uselib += ' OLE'