Fix for PhantomNode packing in MSVC
Changed bool to uint32_t in bit fields to have 4-byte packings for 32 bits: "c++ compilers will allocate bit-fields in memory as follows: several consecutive bit-field members of the same type will be allocated sequentially. As soon as a new type needs to be allocated, it will be aligned with the beginning of the next logical memory block." References: - https://msdn.microsoft.com/en-us/library/ewwyfdbe.aspx - http://stackoverflow.com/questions/308364/c-bitfield-packing-with-bools/308383#308383
This commit is contained in:
parent
dac2f93383
commit
4363fd64c4
@ -63,18 +63,9 @@ struct Hint
|
|||||||
friend std::ostream &operator<<(std::ostream &, const Hint &);
|
friend std::ostream &operator<<(std::ostream &, const Hint &);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
static_assert(sizeof(Hint) == 60 + 4, "Hint is bigger than expected");
|
static_assert(sizeof(Hint) == 60 + 4, "Hint is bigger than expected");
|
||||||
constexpr std::size_t ENCODED_HINT_SIZE = 88;
|
constexpr std::size_t ENCODED_HINT_SIZE = 88;
|
||||||
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
|
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint), "ENCODED_HINT_SIZE does not match size of Hint");
|
||||||
"ENCODED_HINT_SIZE does not match size of Hint");
|
|
||||||
#else
|
|
||||||
// PhantomNode is bigger under windows because MSVC does not support bit packing
|
|
||||||
static_assert(sizeof(Hint) == 72 + 4, "Hint is bigger than expected");
|
|
||||||
constexpr std::size_t ENCODED_HINT_SIZE = 104;
|
|
||||||
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
|
|
||||||
"ENCODED_HINT_SIZE does not match size of Hint");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,13 +149,11 @@ struct PhantomNode
|
|||||||
unsigned reverse_packed_geometry_id;
|
unsigned reverse_packed_geometry_id;
|
||||||
struct ComponentType
|
struct ComponentType
|
||||||
{
|
{
|
||||||
uint32_t id : 31;
|
std::uint32_t id : 31;
|
||||||
bool is_tiny : 1;
|
std::uint32_t is_tiny : 1;
|
||||||
} component;
|
} component;
|
||||||
// bit-fields are broken on Windows
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
static_assert(sizeof(ComponentType) == 4, "ComponentType needs to be 4 bytes big");
|
static_assert(sizeof(ComponentType) == 4, "ComponentType needs to be 4 bytes big");
|
||||||
#endif
|
|
||||||
util::Coordinate location;
|
util::Coordinate location;
|
||||||
util::Coordinate input_location;
|
util::Coordinate input_location;
|
||||||
unsigned short fwd_segment_position;
|
unsigned short fwd_segment_position;
|
||||||
@ -165,11 +163,7 @@ struct PhantomNode
|
|||||||
extractor::TravelMode backward_travel_mode;
|
extractor::TravelMode backward_travel_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
static_assert(sizeof(PhantomNode) == 60, "PhantomNode has more padding then expected");
|
static_assert(sizeof(PhantomNode) == 60, "PhantomNode has more padding then expected");
|
||||||
#else
|
|
||||||
static_assert(sizeof(PhantomNode) == 72, "PhantomNode has more padding then expected");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using PhantomNodePair = std::pair<PhantomNode, PhantomNode>;
|
using PhantomNodePair = std::pair<PhantomNode, PhantomNode>;
|
||||||
|
|
||||||
|
@ -71,13 +71,10 @@ struct SegmentID
|
|||||||
BOOST_ASSERT(!enabled || id != SPECIAL_SEGMENTID);
|
BOOST_ASSERT(!enabled || id != SPECIAL_SEGMENTID);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID id : 31;
|
NodeID id : 31;
|
||||||
bool enabled : 1;
|
std::uint32_t enabled : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// bit-fields are broken on Windows
|
|
||||||
#ifndef _MSC_VER
|
|
||||||
static_assert(sizeof(SegmentID) == 4, "SegmentID needs to be 4 bytes big");
|
static_assert(sizeof(SegmentID) == 4, "SegmentID needs to be 4 bytes big");
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* TYPEDEFS_H */
|
#endif /* TYPEDEFS_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user