@@ -57,7 +57,7 @@ typedef struct {
5757} u64 ;
5858#endif
5959
60- #ifdef ALIGNMENT_WORKAROUND
60+ #if defined( ALIGNMENT_WORKAROUND ) || defined( BIGENDIAN )
6161static inline u64 U64 (u32 low , u32 high )
6262{
6363 u64 self ;
@@ -69,20 +69,18 @@ static inline u64 U64(u32 low, u32 high)
6969}
7070#endif
7171
72- #ifdef ALIGNMENT_WORKAROUND
73- # ifdef BIGENDIAN
74- # define WORD (x ) (u16)((x)[1]+((x)[0]<<8))
75- # define DWORD (x ) (u32)((x)[3]+((x)[2]<<8)+((x)[1]<<16)+((x)[0]<<24))
76- # define QWORD (x ) (U64(DWORD(x+4), DWORD(x)))
77- # else /* BIGENDIAN */
78- # define WORD (x ) (u16)((x)[0]+((x)[1]<<8))
79- # define DWORD (x ) (u32)((x)[0]+((x)[1]<<8)+((x)[2]<<16)+((x)[3]<<24))
80- # define QWORD (x ) (U64(DWORD(x), DWORD(x+4)))
81- # endif /* BIGENDIAN */
82- #else /* ALIGNMENT_WORKAROUND */
72+ /*
73+ * Per SMBIOS v2.8.0 and later, all structures assume a little-endian
74+ * ordering convention.
75+ */
76+ #if defined(ALIGNMENT_WORKAROUND ) || defined(BIGENDIAN )
77+ #define WORD (x ) (u16)((x)[0] + ((x)[1] << 8))
78+ #define DWORD (x ) (u32)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24))
79+ #define QWORD (x ) (U64(DWORD(x), DWORD(x + 4)))
80+ #else /* ALIGNMENT_WORKAROUND || BIGENDIAN */
8381#define WORD (x ) (u16)(*(const u16 *)(x))
8482#define DWORD (x ) (u32)(*(const u32 *)(x))
8583#define QWORD (x ) (*(const u64 *)(x))
86- #endif /* ALIGNMENT_WORKAROUND */
84+ #endif /* ALIGNMENT_WORKAROUND || BIGENDIAN */
8785
8886#endif
0 commit comments