Align the address of the pointer to the fxsave block to a 16-byte boundary (as well as the pointer itself), which the internets seem to suggest is required.
git-svn-id: svn://localhost/ardour2/branches/3.0@12313 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ec2dc36215
commit
312c4e22a7
@ -4,6 +4,7 @@
|
|||||||
#include <cstring> // for memset
|
#include <cstring> // for memset
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "pbd/fpu.h"
|
#include "pbd/fpu.h"
|
||||||
#include "pbd/error.h"
|
#include "pbd/error.h"
|
||||||
@ -67,7 +68,7 @@ FPU::FPU ()
|
|||||||
|
|
||||||
if (cpuflags & (1 << 24)) {
|
if (cpuflags & (1 << 24)) {
|
||||||
|
|
||||||
char* fxbuf = 0;
|
char** fxbuf = 0;
|
||||||
|
|
||||||
/* DAZ wasn't available in the first version of SSE. Since
|
/* DAZ wasn't available in the first version of SSE. Since
|
||||||
setting a reserved bit in MXCSR causes a general protection
|
setting a reserved bit in MXCSR causes a general protection
|
||||||
@ -80,24 +81,27 @@ FPU::FPU ()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef NO_POSIX_MEMALIGN
|
#ifdef NO_POSIX_MEMALIGN
|
||||||
if ((fxbuf = (char *) malloc(512)) == 0)
|
fxbuf = (char **) malloc (sizeof (char *));
|
||||||
|
assert (fxbuf);
|
||||||
|
*fxbuf = (char *) malloc (512);
|
||||||
|
assert (*fxbuf);
|
||||||
#else
|
#else
|
||||||
if (posix_memalign ((void**)&fxbuf, 16, 512))
|
posix_memalign ((void **) &fxbuf, 16, sizeof (char *));
|
||||||
|
assert (fxbuf);
|
||||||
|
posix_memalign ((void **) fxbuf, 16, 512);
|
||||||
|
assert (*fxbuf);
|
||||||
#endif
|
#endif
|
||||||
{
|
|
||||||
error << _("cannot allocate 16 byte aligned buffer for h/w feature detection") << endmsg;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
memset (fxbuf, 0, 512);
|
memset (*fxbuf, 0, 512);
|
||||||
|
|
||||||
asm volatile (
|
asm volatile (
|
||||||
"fxsave (%0)"
|
"fxsave (%0)"
|
||||||
:
|
:
|
||||||
: "r" (fxbuf)
|
: "r" (*fxbuf)
|
||||||
: "memory"
|
: "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
uint32_t mxcsr_mask = *((uint32_t*) &fxbuf[28]);
|
uint32_t mxcsr_mask = *((uint32_t*) &((*fxbuf)[28]));
|
||||||
|
|
||||||
/* if the mask is zero, set its default value (from intel specs) */
|
/* if the mask is zero, set its default value (from intel specs) */
|
||||||
|
|
||||||
@ -109,9 +113,9 @@ FPU::FPU ()
|
|||||||
_flags = Flags (_flags | HasDenormalsAreZero);
|
_flags = Flags (_flags | HasDenormalsAreZero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free (*fxbuf);
|
||||||
free (fxbuf);
|
free (fxbuf);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user