1 #define _XOPEN_SOURCE 600
2 #include <cstring> // for memset
16 unsigned long cpuflags = 0;
24 /* asm notes: although we explicitly save&restore ebx/rbx (stack pointer), we must tell
25 gcc that ebx,rbx is clobbered so that it doesn't try to use it as an intermediate
26 register when storing edx/rdx. gcc 4.3 didn't make this "mistake", but gcc 4.4
27 does, at least on x86_64.
30 #ifndef USE_X86_64_ASM
39 : "%eax", "%ebx", "%ecx", "%edx"
52 : "%rax", "%rbx", "%rcx", "%rdx"
55 #endif /* USE_X86_64_ASM */
57 if (cpuflags & (1<<25)) {
58 _flags = Flags (_flags | (HasSSE|HasFlushToZero));
61 if (cpuflags & (1<<26)) {
62 _flags = Flags (_flags | HasSSE2);
65 if (cpuflags & (1 << 24)) {
69 #ifdef NO_POSIX_MEMALIGN
70 if ((fxbuf = (char *) malloc(512)) == 0)
72 if (posix_memalign ((void**)&fxbuf, 16, 512))
75 error << _("cannot allocate 16 byte aligned buffer for h/w feature detection") << endmsg;
78 memset (fxbuf, 0, 512);
87 uint32_t mxcsr_mask = *((uint32_t*) &fxbuf[28]);
89 /* if the mask is zero, set its default value (from intel specs) */
91 if (mxcsr_mask == 0) {
95 if (mxcsr_mask & (1<<6)) {
96 _flags = Flags (_flags | HasDenormalsAreZero);