Skip to content

Commit a7ce404

Browse files
authored
Add configure checks for cpuid symbols. (PR #116)
Fixes #115. Testing compiler versions is tricky, especially given some vendors wrap up standard compilers as their own, but change version numbers (Apple, Intel) and compilers also often masquerade as another (eg setting GNUC). Instead check for the __get_cpuid_max and __cpuid_count symbols in configure, and adjust the code guards to use the results.
1 parent 3865c88 commit a7ce404

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ AS_IF([test "$ax_cv_builtin_prefetch" = "yes"],
120120
[Define to 1 if you have a __builtin_prefetch])],
121121
[])
122122

123+
dnl Check is cpuid works, needed by rANS_static4x16pr.c.
124+
AC_CHECK_DECLS([__get_cpuid_max, __cpuid_count], [], [], [[#include <cpuid.h>]])
125+
123126
dnl AC_CHECK_LIB([lzma], [lzma_easy_buffer_encode], [
124127
dnl LIBS="-llzma $LIBS"
125128
dnl AC_DEFINE([HAVE_LIBLZMA],1,[Define to 1 if you have the liblzma library.])])

htscodecs/rANS_static4x16pr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,9 @@ unsigned char *rans_uncompress_O1_4x16(unsigned char *in, unsigned int in_size,
824824

825825
static int rans_cpu = 0xFFFF; // all
826826

827-
#if (defined(__GNUC__) || defined(__clang__)) && defined(__x86_64__)
828-
// Icc and Clang both also set __GNUC__ on linux, but not on Windows.
827+
#if defined(__x86_64__) && \
828+
defined(HAVE_DECL___CPUID_COUNT) && HAVE_DECL___CPUID_COUNT && \
829+
defined(HAVE_DECL___GET_CPUID_MAX) && HAVE_DECL___GET_CPUID_MAX
829830
#include <cpuid.h>
830831

831832
#if defined(__clang__) && defined(__has_attribute)

0 commit comments

Comments
 (0)