Set LeafNode alignment to LEAF_PAGE_SIZE bytes
References: - https://github.com/Project-OSRM/osrm-backend/pull/2348#issuecomment-219804408 - http://stackoverflow.com/questions/15523537/alignas-specifier-vs-attribute-aligned-c11 - http://stackoverflow.com/questions/7895869/cross-platform-alignx-macro
This commit is contained in:
parent
a5c5faa21d
commit
843f1a6356
@ -32,6 +32,16 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
// An extended alignment is implementation-defined, so use compiler attributes
|
||||||
|
// until alignas(LEAF_PAGE_SIZE) is compiler-independent.
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#define ALIGNED(x) __declspec(align(x))
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
#define ALIGNED(x) __attribute__ ((aligned(x)))
|
||||||
|
#else
|
||||||
|
#define ALIGNED(x)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace util
|
namespace util
|
||||||
@ -74,13 +84,11 @@ class StaticRTree
|
|||||||
std::uint32_t children[BRANCHING_FACTOR];
|
std::uint32_t children[BRANCHING_FACTOR];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LeafNode
|
struct ALIGNED(LEAF_PAGE_SIZE) LeafNode
|
||||||
{
|
{
|
||||||
LeafNode() : object_count(0), objects() {}
|
LeafNode() : object_count(0), objects() {}
|
||||||
std::uint32_t object_count;
|
std::uint32_t object_count;
|
||||||
std::array<EdgeDataT, LEAF_NODE_SIZE> objects;
|
std::array<EdgeDataT, LEAF_NODE_SIZE> objects;
|
||||||
unsigned char leaf_page_padding[LEAF_PAGE_SIZE - sizeof(std::uint32_t) -
|
|
||||||
sizeof(std::array<EdgeDataT, LEAF_NODE_SIZE>)];
|
|
||||||
};
|
};
|
||||||
static_assert(sizeof(LeafNode) == LEAF_PAGE_SIZE, "LeafNode size does not fit the page size");
|
static_assert(sizeof(LeafNode) == LEAF_PAGE_SIZE, "LeafNode size does not fit the page size");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user