Skip to content

Commit 24b5b99

Browse files
authored
Merge pull request #65 from jamierpond/fix-build-apple-clang
Fix build for Apple Clang -- Apple Clang wasn't broken for me.
2 parents 1fe091b + 98e4f48 commit 24b5b99

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
.vscode
55
test/.vscode
6+
build
7+
.cache

test/inc/zoo/debug/rh/RobinHood.debug.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef ZOO_TEST_ROBINHOOD_DEBUGGING
22
#define ZOO_TEST_ROBINHOOD_DEBUGGING
33

4-
#include "zoo/map/RobinHood.h"
5-
64
#include <sstream>
75
#include <stdio.h>
86

@@ -24,8 +22,9 @@ auto display(
2422
constexpr auto HexPerHash = (MD::NBitsMost + 3) / 4;
2523

2624
char format[60];
27-
snprintf(format, 59, "%%0%dllx %%0%dllx %%0%dllx", HexPerSlot, HexPerSlot, HexPerPSL);
28-
25+
const auto hexPerSlot = static_cast<int>(HexPerSlot);
26+
snprintf(format, 59, "%%0%dllx %%0%dllx %%0%dllx", hexPerSlot, hexPerSlot, HexPerPSL);
27+
2928
auto swarNdx = begin / MD::NSlots;
3029
auto swarEnd = end/MD::NSlots;
3130

@@ -34,8 +33,9 @@ auto display(
3433
auto printLine =
3534
[&]() {
3635
char buffer[100];
37-
sprintf(
36+
snprintf(
3837
buffer,
38+
sizeof(buffer),
3939
format,
4040
initial.at(0), initial.hashes().at(0), initial.PSLs().at(0)
4141
);
@@ -87,7 +87,8 @@ auto satisfiesInvariant(const Table &map, std::size_t begin = 0, std::size_t end
8787
for(auto n = Table::MD::NSlots; n--; ) {
8888
auto current = v.at(0);
8989
if(prior + 1 < current) {
90-
return std::tuple(false, swarIndexBegin * Table::MD::NSlots + Table::MD::NSlots - n - 1);
90+
const std::size_t index = swarIndexBegin * Table::MD::NSlots + Table::MD::NSlots - n - 1;
91+
return std::tuple(false, index);
9192
}
9293
v = v.shiftLanesRight(1);
9394
prior = current;

test/inc/zoo/variant.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <tuple>
44
// provides std::tuple_element to be able to index a pack of types,
55
// indirectly includes type traits and utility
6-
#include <new>
76
#include <zoo/meta/in_place_operations.h>
87
#include <zoo/meta/traits.h>
98

test/map/RobinHood.test.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <algorithm>
1010
#include <regex>
1111
#include <map>
12-
#include <sstream>
1312
#include <fstream>
1413
#include <unordered_map>
1514

@@ -54,22 +53,24 @@ struct V {
5453

5554
std::ostream &operator<<(std::ostream &out, V v) {
5655
char buffer[30];
56+
const auto bufferSize = sizeof(buffer);
5757
char *ptr = buffer;
5858
auto val = v.v;
5959
auto printHalf = [&](auto low, auto high) {
6060
for(auto ndx = low; ndx < high; ++ndx) {
6161
if(v.intraIndex == ndx) {
62-
ptr += sprintf(ptr, "<");
62+
ptr += snprintf(ptr, bufferSize, "<");
6363
}
64-
ptr += sprintf(ptr, "%02lx", val & 0xFF);
64+
const std::size_t va = val & 0xFF;
65+
ptr += snprintf(ptr, bufferSize, "%02lx", va);
6566
if(v.intraIndex == ndx) {
66-
ptr += sprintf(ptr, ">");
67+
ptr += snprintf(ptr, bufferSize, ">");
6768
}
6869
val >>= 8;
6970
}
7071
};
7172
printHalf(0, 4);
72-
ptr += sprintf(ptr, "'");
73+
ptr += snprintf(ptr, bufferSize, "'");
7374
printHalf(4, 8);
7475
out << buffer;
7576
return out;
@@ -143,7 +144,7 @@ TEST_CASE("Robin Hood", "[api][mapping][swar][robin-hood]") {
143144
}
144145
return true;
145146
};
146-
147+
147148
std::regex words("\\w+");
148149
std::sregex_iterator
149150
wordsEnd{},
@@ -227,7 +228,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata basic",
227228
CHECK(std::tuple{0,0} == zoo::rh::impl::peek(table.md_, 0));
228229
CHECK(std::tuple{0,0} == zoo::rh::impl::peek(table.md_, 2));
229230

230-
// If we ask for a skarupke tail
231+
// If we ask for a skarupke tail
231232
FrontendSmall32::Backend be{table.md_.data()};
232233
auto [index, deadline, metadata] =
233234
be.findMisaligned_assumesSkarupkeTail(0x7, 1, [](int i) {return true;});
@@ -331,7 +332,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata psl one",
331332
CHECK(i+1 == missIndex);
332333
CHECK((missIndex)%4 ==
333334
FrontendSmall32::MD{missDeadline}.lsbIndex());
334-
CHECK(0x02 ==
335+
CHECK(0x02 ==
335336
missMetadata.at(FrontendSmall32::MD{missDeadline}.lsbIndex()));
336337
}
337338
{
@@ -375,7 +376,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata psl not one",
375376
CHECK(i-p+4 == missIndex);
376377
CHECK((missIndex)%4 ==
377378
FrontendSmall32::MD{missDeadline}.lsbIndex());
378-
CHECK(0x04 ==
379+
CHECK(0x04 ==
379380
missMetadata.at(FrontendSmall32::MD{missDeadline}.lsbIndex()));
380381
}
381382
}
@@ -449,7 +450,7 @@ TEST_CASE(
449450
m.data_ = MD35u32Ops::SSL{0x0401'8201};
450451
CHECK(0x0000'8001u == m.attemptMatch(SM{hash1}, SM{psl1}).value());
451452
CHECK(0x0000'8001u == SO35u32Ops::attemptMatch(m.data_, SM{hash1}, SM{psl1}).value());
452-
}
453+
}
453454
}
454455

455456
template<typename Container>
@@ -485,7 +486,7 @@ TEST_CASE("RH Validation") {
485486

486487
while(corpus) {
487488
getline(corpus, line);
488-
489+
489490
std::sregex_iterator
490491
wordsEnd{},
491492
wordIterator{line.begin(), line.end(), words};

0 commit comments

Comments
 (0)