Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/extra/libcuckoo
diff options
context:
space:
mode:
Diffstat (limited to 'extra/libcuckoo')
-rw-r--r--extra/libcuckoo/PKGBUILD25
-rw-r--r--extra/libcuckoo/libcuckoo-0.3-resize-unit-test.patch46
2 files changed, 69 insertions, 2 deletions
diff --git a/extra/libcuckoo/PKGBUILD b/extra/libcuckoo/PKGBUILD
index 86f9cd90..ffda60f6 100644
--- a/extra/libcuckoo/PKGBUILD
+++ b/extra/libcuckoo/PKGBUILD
@@ -1,2 +1,23 @@
-# ignoring tests for now, see https://github.com/efficient/libcuckoo/issues/143
-unset check
+# fix tests with https://github.com/efficient/libcuckoo/commit/c749c88864d286c3d875b1de2a082355b7838af7,
+# see https://github.com/efficient/libcuckoo/issues/137
+source+=('libcuckoo-0.3-resize-unit-test.patch')
+md5sums+=('653038be4849c29e459e946ce0cbdac6')
+eval "$(
+ {
+ declare -f prepare || \
+ printf 'prepare() { cd "${pkgname}-${pkgver}"\n}\n'
+ } \
+ | sed '
+ $ i patch -Np1 -i "$srcdir/libcuckoo-0.3-resize-unit-test.patch"
+ '
+)"
+
+# i486 needs -latomic
+if [ "$CARCH" = 'i486' ]; then
+ eval "$(
+ declare -f build | \
+ sed '
+ s/cmake /cmake -DCMAKE_CXX_STANDARD_LIBRARIES=-latomic /
+ '
+ )"
+fi
diff --git a/extra/libcuckoo/libcuckoo-0.3-resize-unit-test.patch b/extra/libcuckoo/libcuckoo-0.3-resize-unit-test.patch
new file mode 100644
index 00000000..839f4873
--- /dev/null
+++ b/extra/libcuckoo/libcuckoo-0.3-resize-unit-test.patch
@@ -0,0 +1,46 @@
+diff -rauN libcuckoo-0.3/tests/unit-tests/test_resize.cc libcuckoo-0.3-resize-unit-test-patch/tests/unit-tests/test_resize.cc
+--- libcuckoo-0.3/tests/unit-tests/test_resize.cc 2020-03-25 15:39:43.000000000 +0100
++++ libcuckoo-0.3-resize-unit-test-patch/tests/unit-tests/test_resize.cc 2022-02-11 06:26:19.181932212 +0100
+@@ -1,4 +1,5 @@
+ #include <array>
++#include <limits>
+
+ #include <catch.hpp>
+
+@@ -45,15 +46,27 @@
+ REQUIRE(UnitTestInternalAccess::reserve_calc<IntIntTable>(
+ 2500000 * slot_per_bucket) == 22);
+
+- REQUIRE(UnitTestInternalAccess::reserve_calc<IntIntTable>(
+- (1ULL << 31) * slot_per_bucket) == 31);
+- REQUIRE(UnitTestInternalAccess::reserve_calc<IntIntTable>(
+- ((1ULL << 31) + 1) * slot_per_bucket) == 32);
+-
+- REQUIRE(UnitTestInternalAccess::reserve_calc<IntIntTable>(
+- (1ULL << 61) * slot_per_bucket) == 61);
+- REQUIRE(UnitTestInternalAccess::reserve_calc<IntIntTable>(
+- ((1ULL << 61) + 1) * slot_per_bucket) == 62);
++ // The maximum number of elements we can ask to reserve without incurring
++ // rounding error when computing a number of buckets is
++ // SIZE_T_MAX-slot_per_bucket(), which will come out to int_div(SIZE_T_MAX -
++ // 1, slot_per_bucket()) buckets.
++ const size_t max_buckets = (
++ std::numeric_limits<size_t>::max() - 1)/slot_per_bucket;
++ // Since the table is always sized in powers of two, our maximum hashpower
++ // comes out to max_hashpower = floor(log2(max_buckets)). We compute this in
++ // a numerically-stable fashion.
++ size_t max_hashpower = 0;
++ for (; (static_cast<size_t>(1) << (max_hashpower + 1)) <= max_buckets; ++max_hashpower);
++ // Test the boundary between max_hashpower-1 and max_hashpower.
++ const size_t max_elems_before_max_hashpower = (
++ static_cast<size_t>(1) << (max_hashpower - 1)) * slot_per_bucket;
++ REQUIRE(UnitTestInternalAccess::reserve_calc<IntIntTable>(
++ max_elems_before_max_hashpower) == (max_hashpower - 1));
++ REQUIRE(UnitTestInternalAccess::reserve_calc<IntIntTable>(
++ max_elems_before_max_hashpower + 1) == max_hashpower);
++ // Test the maximum number of elements.
++ const size_t max_elems = (static_cast<size_t>(1) << max_hashpower) * slot_per_bucket;
++ REQUIRE(UnitTestInternalAccess::reserve_calc<IntIntTable>(max_elems) == max_hashpower);
+ }
+
+ struct my_type {