diff options
| author | 2025-08-20 14:31:59 +0330 | |
|---|---|---|
| committer | 2025-08-20 14:31:59 +0330 | |
| commit | 4c0d59ff16f76dcbe0c16cf34e6a09dbc2422f93 (patch) | |
| tree | 997d0e0c3e4579dd80ef36869a16fe10820fe647 /pu2/pu2.c | |
| parent | added compat flags for easier cross-compilation (diff) | |
compat flags explanation
Diffstat (limited to 'pu2/pu2.c')
| -rw-r--r-- | pu2/pu2.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -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) { |
