Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 1 | implement timer implementation for mips platform |
| 2 | |
| 3 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 4 | --- a/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h |
| 5 | +++ b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 6 | @@ -158,6 +158,12 @@ static inline tokutime_t toku_time_now(v |
| 7 | uint64_t cycles; |
| 8 | asm volatile("rdcycle %0" : "=r"(cycles)); |
| 9 | return cycles; |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 10 | +#elif defined(__mips__) |
| 11 | + // mips apparently only allows rdtsc for superusers, so we fall |
| 12 | + // back to gettimeofday. It's possible clock_gettime would be better. |
| 13 | + struct timeval tv; |
| 14 | + gettimeofday(&tv, nullptr); |
| 15 | + return (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
| 16 | #else |
| 17 | #error No timer implementation for this platform |
| 18 | #endif |