diff options
author | Yun Pan <dinoallo@netc.it> | 2022-03-15 22:45:12 +0800 |
---|---|---|
committer | Yixun Lan <dlan@gentoo.org> | 2022-03-19 12:09:20 +0800 |
commit | b005163fb832df44f7c0cabeb7b54b7d7ea61080 (patch) | |
tree | dbc5a7a09f27a0cc225195c488b5e7591d2d989f /dev-libs | |
parent | dev-lang/python: save/restore PYTHONDONTWRITEBYTECODE for USE=pgo (diff) | |
download | gentoo-b005163fb832df44f7c0cabeb7b54b7d7ea61080.tar.gz gentoo-b005163fb832df44f7c0cabeb7b54b7d7ea61080.tar.bz2 gentoo-b005163fb832df44f7c0cabeb7b54b7d7ea61080.zip |
dev-libs/rocksdb: add timer for riscv platform
See: https://bugs.gentoo.org/834855#c3
Related upstream PR: https://github.com/facebook/rocksdb/pull/9215
Bug: https://bugs.gentoo.org/834855
Signed-off-by: Yun Pan <dinoallo@netc.it>
Signed-off-by: Yixun Lan <dlan@gentoo.org>
Diffstat (limited to 'dev-libs')
-rw-r--r-- | dev-libs/rocksdb/files/rocksdb-6.17.3-add_timer_for_riscv.patch | 40 | ||||
-rw-r--r-- | dev-libs/rocksdb/rocksdb-6.17.3.ebuild | 1 |
2 files changed, 41 insertions, 0 deletions
diff --git a/dev-libs/rocksdb/files/rocksdb-6.17.3-add_timer_for_riscv.patch b/dev-libs/rocksdb/files/rocksdb-6.17.3-add_timer_for_riscv.patch new file mode 100644 index 000000000000..b98cc9dc5fd6 --- /dev/null +++ b/dev-libs/rocksdb/files/rocksdb-6.17.3-add_timer_for_riscv.patch @@ -0,0 +1,40 @@ +Add timer for riscv. +Upstream PR status: https://github.com/facebook/rocksdb/pull/9215 +This PR hasn't been merged into the main branch. +https://bugs.gentoo.org/834855 + +--- a/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h ++++ b/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +@@ -101,7 +101,7 @@ int toku_clock_gettime(clockid_t clk_id, struct timespec *ts) __attribute__((__v + typedef uint64_t tokutime_t; // Time type used in by tokutek timers. + + #if 0 +-// The value of tokutime_t is not specified here. ++// The value of tokutime_t is not specified here. + // It might be microseconds since 1/1/1970 (if gettimeofday() is + // used), or clock cycles since boot (if rdtsc is used). Or something + // else. +@@ -133,6 +133,23 @@ static inline tokutime_t toku_time_now(void) { + return result; + #elif defined(__powerpc__) + return __ppc_get_timebase(); ++#elif defined(__riscv) && __riscv_xlen == 32 ++ uint32_t cycles_lo, cycles_hi0, cycles_hi1; ++ // Implemented in assembly because Clang insisted on branching. ++ asm volatile( ++ "rdcycleh %0\n" ++ "rdcycle %1\n" ++ "rdcycleh %2\n" ++ "sub %0, %0, %2\n" ++ "seqz %0, %0\n" ++ "sub %0, zero, %0\n" ++ "and %1, %1, %0\n" ++ : "=r"(cycles_hi0), "=r"(cycles_lo), "=r"(cycles_hi1)); ++ return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo; ++#elif defined(__riscv) && __riscv_xlen == 64 ++ uint64_t cycles; ++ asm volatile("rdcycle %0" : "=r"(cycles)); ++ return cycles; + #else + #error No timer implementation for this platform + #endif diff --git a/dev-libs/rocksdb/rocksdb-6.17.3.ebuild b/dev-libs/rocksdb/rocksdb-6.17.3.ebuild index 76c4d651f8af..b01c64b2d2f8 100644 --- a/dev-libs/rocksdb/rocksdb-6.17.3.ebuild +++ b/dev-libs/rocksdb/rocksdb-6.17.3.ebuild @@ -27,6 +27,7 @@ RDEPEND="${DEPEND}" PATCHES=( "${FILESDIR}"/${PN}-6.14.6-libatomic.patch + "${FILESDIR}"/${PN}-6.17.3-add_timer_for_riscv.patch ) src_configure() { |