diff --git a/include/ircd/ctx/prof.h b/include/ircd/ctx/prof.h index 87694df66..b204605f1 100644 --- a/include/ircd/ctx/prof.h +++ b/include/ircd/ctx/prof.h @@ -33,7 +33,7 @@ namespace ircd::ctx::prof struct ticker; // util - ulong rdtsc(); + unsigned long long rdtsc(); string_view reflect(const event &); // totals @@ -97,3 +97,19 @@ struct ircd::ctx::prof::ticker // monotonic counters for events std::array()> event {{0}}; }; + +#if defined(__x86_64__) || defined(__i386__) +inline unsigned long long +__attribute__((flatten, always_inline, gnu_inline, artificial)) +ircd::ctx::prof::rdtsc() +{ + return __builtin_ia32_rdtsc(); +} +#else +inline unsigned long long +ircd::ctx::prof::rdtsc() +{ + static_assert(false, "TODO: Implement fallback here"); + return 0; +} +#endif diff --git a/ircd/ctx.cc b/ircd/ctx.cc index af0567d85..cf5873a94 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -1867,25 +1867,6 @@ ircd::ctx::prof::reflect(const event &e) return "?????"; } -#ifdef HAVE_X86INTRIN_H -ulong -ircd::ctx::prof::rdtsc() -{ - return __rdtsc(); -} -#else -ulong -ircd::ctx::prof::rdtsc() -{ - static_assert - ( - 0, "TODO: Implement fallback here" - ); - - return 0; -} -#endif - /////////////////////////////////////////////////////////////////////////////// // // ctx_ole.h