Prevent unaligned memory access in adlib
This removes the last warnings in this area; in this case changing endianess is not used for accessing emulated memory, just to flip few values to low endian for storage.
This commit is contained in:
parent
72122b731b
commit
4d674102d0
3 changed files with 35 additions and 5 deletions
|
@ -105,6 +105,36 @@ static INLINE void host_writed(HostPt off,Bit32u val) {
|
|||
|
||||
#endif
|
||||
|
||||
// host_to_le functions allow for byte order conversion on big endian
|
||||
// architectures while respecting memory alignment on low endian.
|
||||
//
|
||||
// It is extremely unlikely that we'll ever try to compile on big endian arch
|
||||
// with a compiler missing __builtin_bswap*, so let's not overcomplicate
|
||||
// things.
|
||||
//
|
||||
// __builtin_bswap* is supported since GCC 4.3 and Clang 3.4
|
||||
|
||||
#if defined(WORDS_BIGENDIAN)
|
||||
|
||||
constexpr static INLINE uint16_t host_to_le(uint16_t val) {
|
||||
return __builtin_bswap16(val);
|
||||
}
|
||||
|
||||
constexpr static INLINE uint32_t host_to_le(uint32_t val) {
|
||||
return __builtin_bswap32(val);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
constexpr static INLINE uint16_t host_to_le(uint16_t val) {
|
||||
return val;
|
||||
}
|
||||
|
||||
constexpr static INLINE uint32_t host_to_le(uint32_t val) {
|
||||
return val;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static INLINE void var_write(Bit8u * var, Bit8u val) {
|
||||
host_writeb(var, val);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue