1 #define _XOPEN_SOURCE 600
2 #include <cstring> // for memset
16 unsigned long cpuflags
= 0;
25 #ifndef USE_X86_64_ASM
34 : "%eax", "%ecx", "%edx"
39 /* asm notes: although we explicitly save&restore rbx, we must tell
40 gcc that ebx,rbx is clobbered so that it doesn't try to use it as an intermediate
41 register when storing rbx. gcc 4.3 didn't make this "mistake", but gcc 4.4
42 does, at least on x86_64.
53 : "%rax", "%rbx", "%rcx", "%rdx"
56 #endif /* USE_X86_64_ASM */
58 if (cpuflags
& (1<<25)) {
59 _flags
= Flags (_flags
| (HasSSE
|HasFlushToZero
));
62 if (cpuflags
& (1<<26)) {
63 _flags
= Flags (_flags
| HasSSE2
);
66 if (cpuflags
& (1 << 24)) {
70 #ifdef NO_POSIX_MEMALIGN
71 if ((fxbuf
= (char *) malloc(512)) == 0)
73 if (posix_memalign ((void**)&fxbuf
, 16, 512))
76 error
<< _("cannot allocate 16 byte aligned buffer for h/w feature detection") << endmsg
;
79 memset (fxbuf
, 0, 512);
88 uint32_t mxcsr_mask
= *((uint32_t*) &fxbuf
[28]);
90 /* if the mask is zero, set its default value (from intel specs) */
92 if (mxcsr_mask
== 0) {
96 if (mxcsr_mask
& (1<<6)) {
97 _flags
= Flags (_flags
| HasDenormalsAreZero
);