Skip to content

Commit

Permalink
addpkg: rocksdb
Browse files Browse the repository at this point in the history
  • Loading branch information
XieJiSS authored and felixonmars committed Nov 26, 2021
1 parent 3b1b1e4 commit 8e42b23
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
26 changes: 26 additions & 0 deletions rocksdb/0000-toku-time-riscv.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h 2021-11-25 22:20:08.918983110 +0800
+++ utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h 2021-11-25 23:57:44.352396324 +0800
@@ -133,6 +133,23 @@
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
23 changes: 23 additions & 0 deletions rocksdb/riscv64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- PKGBUILD
+++ PKGBUILD
@@ -10,8 +10,18 @@ url="https://rocksdb.org/"
license=(GPL2 Apache)
depends=(bzip2 jemalloc lz4 snappy zlib zstd tbb liburing)
makedepends=(python)
-source=(rocksdb-$pkgver.tar.gz::https://github.com/facebook/rocksdb/archive/v$pkgver.tar.gz)
-sha256sums=('b793066463da71d31a46f31946e4fca435a7c3e73435e2bb1d062d95e0a20116')
+source=(rocksdb-$pkgver.tar.gz::https://github.com/facebook/rocksdb/archive/v$pkgver.tar.gz
+ 0000-toku-time-riscv.patch)
+sha256sums=('b793066463da71d31a46f31946e4fca435a7c3e73435e2bb1d062d95e0a20116'
+ '9bd4ddbbcad2da293026be27921057f096370894efbb16314246cbf9d463f4a2')
+
+prepare() {
+ cd rocksdb-$pkgver
+ sed -i "s/-lpthread/-pthread/" build_tools/build_detect_platform examples/Makefile
+
+ # see https://github.com/facebook/rocksdb/pull/9215
+ patch -p0 -i ../0000-toku-time-riscv.patch
+}

build() {
cd rocksdb-$pkgver

0 comments on commit 8e42b23

Please sign in to comment.