From 4c0d59ff16f76dcbe0c16cf34e6a09dbc2422f93 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Wed, 20 Aug 2025 14:31:59 +0330 Subject: compat flags explanation --- pu2/pu2.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'pu2/pu2.c') diff --git a/pu2/pu2.c b/pu2/pu2.c index 076261c..85c28f4 100644 --- a/pu2/pu2.c +++ b/pu2/pu2.c @@ -647,12 +647,20 @@ unsigned long long rdtsc(void) { #endif } +#ifndef PU2_BAD_CLOCK clock_t ntime() { struct timespec t; clock_gettime(CLOCK_MONOTONIC_RAW, &t); return t.tv_nsec + t.tv_sec * 1e9; } +#else +clock_t ntime() { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_sec * 1000000000 + tv.tv_usec * 1000; +} +#endif // bench: measure using clock() double bench_cycle(int instr) { @@ -729,8 +737,14 @@ sleep_nano(int nanoseconds) { } } -[[clang::always_inline]] sleep_micro(int microseconds) { sleep_nano(microseconds * 1e3); } -[[clang::always_inline]] sleep_milli(int milliseconds) { sleep_nano(milliseconds * 1e6); } +#ifdef PU2_OLD_CLANG + #define inline() __attribute__((always_inline)) +#else + #define inline() [[clang::always_inline]] +#endif + +inline() sleep_micro(int microseconds) { sleep_nano(microseconds * 1e3); } +inline() sleep_milli(int milliseconds) { sleep_nano(milliseconds * 1e6); } // benchmark: run target for all opcodes and print summary benchmark(double (*target)(int), const char *mode_label) { -- cgit v1.2.3