From 42298a911a3f6c18581f2864d018249494fdf575 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Tue, 28 May 2024 13:22:15 -0700 Subject: [PATCH] Prepare to add fdb implementation Fixes a end iter deref and remove rpath from test --- CMakeLists.txt | 11 ++++++++++- Facade.h | 12 ++++-------- VersionedMap.cpp | 8 ++++---- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc9a8fb..9e10f3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,14 +184,23 @@ if(BUILD_TESTING) add_executable(driver TestDriver.cpp FacadeFuzz.cpp) target_compile_options(driver PRIVATE ${TEST_FLAGS}) target_link_libraries(driver PRIVATE ${PROJECT_NAME}) + set_target_properties(driver PROPERTIES SKIP_BUILD_RPATH ON) + if(APPLE) + set(LD_PATH DYLD_LIBRARY_PATH) + else() + set(LD_PATH LD_LIBRARY_PATH) + endif() foreach(TEST ${CORPUS_TESTS}) get_filename_component(hash ${TEST} NAME) add_test(NAME versioned_map_blackbox_${hash} COMMAND driver ${TEST}) + set_tests_properties( + versioned_map_blackbox_${hash} + PROPERTIES ENVIRONMENT ${LD_PATH}=${CMAKE_BINARY_DIR}/versioned-map) endforeach() add_executable(bench Bench.cpp) - target_compile_options(bench PRIVATE ${TEST_FLAGS}) target_link_libraries(bench PRIVATE ${PROJECT_NAME} nanobench) + set_target_properties(bench PROPERTIES SKIP_BUILD_RPATH ON) # symbol visibility tests if(NOT CMAKE_BUILD_TYPE STREQUAL Debug) diff --git a/Facade.h b/Facade.h index 2c3722f..d9c7a25 100644 --- a/Facade.h +++ b/Facade.h @@ -44,9 +44,6 @@ struct Facade { return result; } - static const uint8_t zero_[] = {0}; - static const String zero{zero_, 1}; - if (reverse) { weaselab::VersionedMap::Iterator iter = versionedIter[1]; weaselab::VersionedMap::Iterator endIter = versionedIter[0]; @@ -123,13 +120,11 @@ struct Facade { m.type == weaselab::VersionedMap::Set || m.param2Len == 0 ? weaselab::VersionedMap::Key{m.param1, m.param1Len + 1} : weaselab::VersionedMap::Key{m.param2, m.param2Len}; - auto c = unversionedIter->first <=> mBegin; - for (; unversionedIter != facade->unversioned.end() && c < 0 && - limit > 0;) { + for (; unversionedIter != facade->unversioned.end() && + (unversionedIter->first <=> mBegin) < 0 && limit > 0;) { result.push_back(*unversionedIter); --limit; ++unversionedIter; - c = unversionedIter->first <=> mBegin; } if (limit == 0) { return result; @@ -147,7 +142,8 @@ struct Facade { break; } if (m.type == weaselab::VersionedMap::Set || m.param2Len == 0) { - if (unversionedIter != facade->unversioned.end() && c == 0) { + if (unversionedIter != facade->unversioned.end() && + (unversionedIter->first <=> mBegin) == 0) { ++unversionedIter; } assert(unversionedIter == diff --git a/VersionedMap.cpp b/VersionedMap.cpp index 6fe6e27..e771efd 100644 --- a/VersionedMap.cpp +++ b/VersionedMap.cpp @@ -596,7 +596,7 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl { finger.clear(); - bool ignored; + bool ignored = false; finger.push(root, ignored); for (;;) { @@ -810,7 +810,7 @@ struct __attribute__((__visibility__("hidden"))) VersionedMap::Impl { Finger finger; if (continueKey.len == 0) { // Set finger to last entry in tree - bool ignored; + bool ignored = false; finger.push(latestRoot, ignored); uint32_t c; while ((c = child(finger.backNode(), true, @@ -1120,7 +1120,7 @@ VersionedMap::Iterator &VersionedMap::Iterator::operator--() { // Handle decrementing end if (impl->finger.searchPathSize() == 0) { - bool ignored; + bool ignored = false; impl->finger.push( impl->map->roots.getThreadSafeHandle().rootForVersion(impl->version), ignored); @@ -1247,7 +1247,7 @@ VersionedMap::Iterator VersionedMap::begin(int64_t version) const { result.impl = new (safe_malloc(sizeof(Iterator::Impl))) Iterator::Impl(); result.impl->version = version; - bool ignored; + bool ignored = false; result.impl->finger.push( impl->roots.getThreadSafeHandle().rootForVersion(version), ignored); if (result.impl->finger.backNode() == 0) {