Skip to content

Commit

Permalink
win/configure: check whether cpuid-header natively supported for the …
Browse files Browse the repository at this point in the history
…target architecture (possible fix for [d58e31517203396e])
  • Loading branch information
sebres committed Jan 2, 2025
1 parent 3a7feaf commit 048d824
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 2 deletions.
74 changes: 74 additions & 0 deletions win/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4947,6 +4947,80 @@ _ACEOF
fi
# See if the compiler supports cpuid header.
if test "${GCC}" = "yes" ; then
echo "$as_me:$LINENO: checking for cpuid-header support in compiler" >&5
echo $ECHO_N "checking for cpuid-header support in compiler... $ECHO_C" >&6
if test "${tcl_cv_cpuidhead+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))))
# include <cpuid.h>
#endif
int
main ()
{
unsigned int regs;
__get_cpuid(0, &regs, &regs, &regs, &regs);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
tcl_cv_cpuidhead=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
tcl_cv_cpuidhead=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $tcl_cv_cpuidhead" >&5
echo "${ECHO_T}$tcl_cv_cpuidhead" >&6
if test "$tcl_cv_cpuidhead" = "yes"; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_CPUID_H 1
_ACEOF
fi
fi
# See if the <wspiapi.h> header file is present
echo "$as_me:$LINENO: checking for wspiapi.h" >&5
Expand Down
22 changes: 22 additions & 0 deletions win/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,28 @@ if test "$tcl_cv_intrinsics" = "yes"; then
[Defined when the compilers supports intrinsics])
fi

# See if the compiler supports cpuid header.

if test "${GCC}" = "yes" ; then
AC_CACHE_CHECK(for cpuid-header support in compiler,
tcl_cv_cpuidhead,
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))))
# include <cpuid.h>
#endif
]], [[
unsigned int regs;
__get_cpuid(0, &regs, &regs, &regs, &regs);
]])],
[tcl_cv_cpuidhead=yes],
[tcl_cv_cpuidhead=no])
)
if test "$tcl_cv_cpuidhead" = "yes"; then
AC_DEFINE(HAVE_CPUID_H, 1,
[Defined when the compilers supports cpuid header])
fi
fi

# See if the <wspiapi.h> header file is present

AC_CACHE_CHECK(for wspiapi.h,
Expand Down
4 changes: 2 additions & 2 deletions win/tclWin32Dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/

#include "tclWinInt.h"
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))))
#if defined(HAVE_CPUID_H)
# include <cpuid.h>
#elif defined(HAVE_INTRIN_H)
# include <intrin.h>
Expand Down Expand Up @@ -663,7 +663,7 @@ TclWinCPUID(
{
int status = TCL_ERROR;

#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))))
#if defined(HAVE_CPUID_H)

__get_cpuid(index, &regsPtr[0], &regsPtr[1], &regsPtr[2], &regsPtr[3]);
status = TCL_OK;
Expand Down

0 comments on commit 048d824

Please sign in to comment.