Fix the rdtscp detection bug and add prefix for the macro.

This commit is contained in:
guangli-dai 2022-12-14 17:23:41 -08:00 committed by Qi Wang
parent 8b64be3441
commit 31e01a98f1
3 changed files with 9 additions and 3 deletions

View File

@ -522,10 +522,10 @@ typedef unsigned __int32 uint32_t;
return 0; return 0;
]])], ]])],
[je_cv_rdtscp=yes], [je_cv_rdtscp=yes],
[je_cv_rdstcp=no], [je_cv_rdtscp=no],
[je_cv_rdtscp=no])) [je_cv_rdtscp=no]))
if test "x${je_cv_rdtscp}" = "xyes"; then if test "x${je_cv_rdtscp}" = "xyes"; then
AC_DEFINE([HAVE_RDTSCP], 1, []) AC_DEFINE([JEMALLOC_HAVE_RDTSCP], [ ], [ ])
fi fi
fi fi
;; ;;

View File

@ -443,4 +443,10 @@
/* If defined, use volatile asm during benchmarks. */ /* If defined, use volatile asm during benchmarks. */
#undef JEMALLOC_HAVE_ASM_VOLATILE #undef JEMALLOC_HAVE_ASM_VOLATILE
/*
* If defined, support the use of rdtscp to get the time stamp counter
* and the processor ID.
*/
#undef JEMALLOC_HAVE_RDTSCP
#endif /* JEMALLOC_INTERNAL_DEFS_H_ */ #endif /* JEMALLOC_INTERNAL_DEFS_H_ */

View File

@ -14,7 +14,7 @@ malloc_getcpu(void) {
return GetCurrentProcessorNumber(); return GetCurrentProcessorNumber();
#elif defined(JEMALLOC_HAVE_SCHED_GETCPU) #elif defined(JEMALLOC_HAVE_SCHED_GETCPU)
return (malloc_cpuid_t)sched_getcpu(); return (malloc_cpuid_t)sched_getcpu();
#elif defined(HAVE_RDTSCP) #elif defined(JEMALLOC_HAVE_RDTSCP)
unsigned int ax, cx, dx; unsigned int ax, cx, dx;
asm volatile("rdtscp" : "=a"(ax), "=d"(dx), "=c"(cx) ::); asm volatile("rdtscp" : "=a"(ax), "=d"(dx), "=c"(cx) ::);
return (malloc_cpuid_t)(dx & 0xfff); return (malloc_cpuid_t)(dx & 0xfff);