Skip to content

Commit

Permalink
aesni: select __cpuid impl based on compiler type
Browse files Browse the repository at this point in the history
MinGW provides both kinds of implementations of `__cpuid`,
but since `cpuid.h` is provided by GNUC, so we should choose
the implementation by the compiler type instead of OS type.

Signed-off-by: Pengyu Lv <[email protected]>
  • Loading branch information
lpy4105 committed Oct 19, 2023
1 parent 79d7faf commit f3c6e2e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions library/aesni.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
#if defined(MBEDTLS_AESNI_HAVE_CODE)

#if MBEDTLS_AESNI_HAVE_CODE == 2
#if !defined(_WIN32)
#if defined(__GNUC__)
#include <cpuid.h>
#else
#elif defined(_MSC_VER)
#include <intrin.h>
#else
#error "`__cpuid` required by MBEDTLS_AESNI_C is not supported by the compiler"
#endif
#include <immintrin.h>
#endif
Expand All @@ -58,7 +60,7 @@ int mbedtls_aesni_has_support(unsigned int what)
if (!done) {
#if MBEDTLS_AESNI_HAVE_CODE == 2
static int info[4] = { 0, 0, 0, 0 };
#if defined(_WIN32)
#if defined(_MSC_VER)
__cpuid(info, 1);
#else
__cpuid(1, info[0], info[1], info[2], info[3]);
Expand Down

0 comments on commit f3c6e2e

Please sign in to comment.