1
0
mirror of https://github.com/BLAKE2/libb2 synced 2024-11-23 00:32:03 +01:00

Merge pull request #33 from noloader/cpuid

Fix missing xgetbv on downlevel compilers
This commit is contained in:
Samuel Neves 2020-06-30 23:37:54 +01:00 committed by GitHub
commit 37e4b4b802
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23

@ -64,11 +64,13 @@ static inline void cpuid( uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t
#endif
}
/* xgetbv insn is GCC 4.5 and above. The byte codes sidestep the limitation */
/* Also see http://www.agner.org/optimize/vectorclass/read.php?i=65 */
static inline uint64_t xgetbv(uint32_t xcr)
{
uint32_t a, d;
__asm__ __volatile__(
"xgetbv"
".byte 0x0f, 0x01, 0xd0"
: "=a"(a),"=d"(d)
: "c"(xcr)
);