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
2
INSTALL
2
INSTALL
|
@ -50,7 +50,7 @@ alsa-lib (optional)
|
|||
|
||||
If you want compile from developer sources (SVN) under a unix system, you will need:
|
||||
- Subversion to checkout the sources, or gzip and tar to unpack them from archive
|
||||
- GCC (>=4.8.1) or Clang (>=3.3)
|
||||
- GCC (>=4.8.1) or Clang (>=3.4)
|
||||
- automake (>=1.6)
|
||||
- autoconf (>=2.50)
|
||||
- autoconf-archive (>=2009.x)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -328,10 +328,10 @@ class Capture {
|
|||
if ( handle ) {
|
||||
ClearBuf();
|
||||
/* Endianize the header and write it to beginning of the file */
|
||||
var_write( &header.versionHigh, header.versionHigh );
|
||||
var_write( &header.versionLow, header.versionLow );
|
||||
var_write( &header.commands, header.commands );
|
||||
var_write( &header.milliseconds, header.milliseconds );
|
||||
header.versionHigh = host_to_le(header.versionHigh);
|
||||
header.versionLow = host_to_le(header.versionLow);
|
||||
header.commands = host_to_le(header.commands);
|
||||
header.milliseconds = host_to_le(header.milliseconds);
|
||||
fseek( handle, 0, SEEK_SET );
|
||||
fwrite( &header, 1, sizeof( header ), handle );
|
||||
fclose( handle );
|
||||
|
|
Loading…
Add table
Reference in a new issue