Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame^] | 1 | From 2ebc0ff33e41d23e4d3aec1a86f3d8bd4be410e7 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Thu, 21 Mar 2024 14:14:58 +0800 |
| 4 | Subject: [PATCH] Implement timer implementation for mips platform |
| 5 | |
| 6 | Upstream-Status: Pending |
| 7 | |
| 8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 9 | --- |
| 10 | .../lock/range/range_tree/lib/portability/toku_time.h | 6 ++++++ |
| 11 | 1 file changed, 6 insertions(+) |
| 12 | |
| 13 | diff --git a/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h |
| 14 | index 0a7488c397..ad7d9f2124 100644 |
| 15 | --- a/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h |
| 16 | +++ b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h |
| 17 | @@ -162,6 +162,12 @@ static inline tokutime_t toku_time_now(void) { |
| 18 | unsigned long result; |
| 19 | asm volatile ("rdtime.d\t%0,$r0" : "=r" (result)); |
| 20 | return result; |
| 21 | +#elif defined(__mips__) |
| 22 | + // mips apparently only allows rdtsc for superusers, so we fall |
| 23 | + // back to gettimeofday. It's possible clock_gettime would be better. |
| 24 | + struct timeval tv; |
| 25 | + gettimeofday(&tv, nullptr); |
| 26 | + return (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec; |
| 27 | #else |
| 28 | #error No timer implementation for this platform |
| 29 | #endif |
| 30 | -- |
| 31 | 2.25.1 |
| 32 | |