Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 32-bit and old PDAL compilation issues #44

Merged
merged 2 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions epf/Reprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
****************************************************************************/


// This include is necessary for released PDAL 2.0 and earlier, as it wasn't included in
// FileUtils.hpp.
#include <vector>
#include <pdal/util/FileUtils.hpp>

#include "Reprocessor.hpp"
Expand Down
31 changes: 23 additions & 8 deletions untwine/VoxelKey.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,30 @@ namespace std
{
template<> struct hash<untwine::VoxelKey>
{
std::size_t operator()(const untwine::VoxelKey& k) const noexcept
size_t operator()(const untwine::VoxelKey& k) const noexcept
{
static_assert(sizeof(size_t) > sizeof(int), "wrong assumption that size_t is 64 bits");

// For this to work well we just assume that the values are no more than than 16 bits.
size_t t = size_t(k.x()) << 48;
t |= size_t(k.y()) << 32;
t |= size_t(k.z()) << 16;
t |= size_t(k.level());
size_t t;

static_assert(sizeof(size_t) == sizeof(uint64_t) ||
sizeof(size_t) == sizeof(uint32_t),
"Only systems with 32 and 64 bit size_t are currently supported.");

// Counting on the compiler to optimize away the wrong branch.
if (sizeof(size_t) == sizeof(uint64_t))
{
// For this to work well we just assume that the values are no more than 16 bits.
t = size_t(k.x()) << 48;
t |= size_t(k.y()) << 32;
t |= size_t(k.z()) << 16;
t |= size_t(k.level());
}
else if (sizeof(size_t) == sizeof(uint32_t))
{
t = size_t((k.x() << 24) | 0xFF000000);
t |= size_t((k.y() << 16) | 0xFF0000);
t |= size_t((k.z() << 8) | 0xFF00);
t |= size_t(k.level() | 0xFF);
}
return t;
}
};
Expand Down