[PATCH v2 1/9] eal: use rdtsc intrinsic when compiling with msvc
Bruce Richardson
bruce.richardson at intel.com
Wed Apr 5 10:59:54 CEST 2023
On Tue, Apr 04, 2023 at 01:07:19PM -0700, Tyler Retzlaff wrote:
> Inline assembly is not supported for msvc x64 instead use __rdtsc
> intrinsic.
>
> Signed-off-by: Tyler Retzlaff <roretzla at linux.microsoft.com>
> ---
> lib/eal/x86/include/rte_cycles.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/lib/eal/x86/include/rte_cycles.h b/lib/eal/x86/include/rte_cycles.h
> index a461a4d..0c142ce 100644
> --- a/lib/eal/x86/include/rte_cycles.h
> +++ b/lib/eal/x86/include/rte_cycles.h
> @@ -6,6 +6,10 @@
> #ifndef _RTE_CYCLES_X86_64_H_
> #define _RTE_CYCLES_X86_64_H_
>
> +#ifdef RTE_TOOLCHAIN_MSVC
> +#include <intrin.h>
> +#endif
> +
> #ifdef __cplusplus
> extern "C" {
> #endif
> @@ -23,6 +27,7 @@
> static inline uint64_t
> rte_rdtsc(void)
> {
> +#ifndef RTE_TOOLCHAIN_MSVC
> union {
> uint64_t tsc_64;
> RTE_STD_C11
> @@ -47,6 +52,9 @@
> "=a" (tsc.lo_32),
> "=d" (tsc.hi_32));
> return tsc.tsc_64;
> +#else
> + return __rdtsc();
> +#endif
> }
Checking with google it seems that gcc/clang have an __rdtsc intrinsic as
well, so we may be able to avoid ifdefs here completely.
/Bruce
More information about the dev
mailing list