summaryrefslogtreecommitdiff
path: root/types.h
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-10-03 08:05:59 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-10-03 08:05:59 +0200
commitbacae0071984c60d92ec6a15fc1560186f8aad32 (patch)
tree5d8e0742dfef7e237419018f84f2380ac3efc136 /types.h
parent85e233a539b5450d6bfc9ebd18142527a7114ffe (diff)
parent7c994b7f6bda56308e5f1d50651d5951de92198f (diff)
Update upstream source from tag 'upstream/3.2'
Update to upstream version '3.2' with Debian dir 3fa673caf263a3f5704adb0ac42dd3c9852ddd38
Diffstat (limited to 'types.h')
-rw-r--r--types.h27
1 files changed, 12 insertions, 15 deletions
diff --git a/types.h b/types.h
index 19d803d..51c32d7 100644
--- a/types.h
+++ b/types.h
@@ -11,8 +11,7 @@ typedef unsigned int u32;
/*
* You may use the following defines to adjust the type definitions
* depending on the architecture:
- * - Define BIGENDIAN on big-endian systems. Untested, as all target
- * systems to date are little-endian.
+ * - Define BIGENDIAN on big-endian systems.
* - Define ALIGNMENT_WORKAROUND if your system doesn't support
* non-aligned memory access. In this case, we use a slower, but safer,
* memory access method. This should be done automatically in config.h
@@ -31,7 +30,7 @@ typedef struct {
} u64;
#endif
-#ifdef ALIGNMENT_WORKAROUND
+#if defined(ALIGNMENT_WORKAROUND) || defined(BIGENDIAN)
static inline u64 U64(u32 low, u32 high)
{
u64 self;
@@ -43,20 +42,18 @@ static inline u64 U64(u32 low, u32 high)
}
#endif
-#ifdef ALIGNMENT_WORKAROUND
-# ifdef BIGENDIAN
-# define WORD(x) (u16)((x)[1] + ((x)[0] << 8))
-# define DWORD(x) (u32)((x)[3] + ((x)[2] << 8) + ((x)[1] << 16) + ((x)[0] << 24))
-# define QWORD(x) (U64(DWORD(x + 4), DWORD(x)))
-# else /* BIGENDIAN */
-# define WORD(x) (u16)((x)[0] + ((x)[1] << 8))
-# define DWORD(x) (u32)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24))
-# define QWORD(x) (U64(DWORD(x), DWORD(x + 4)))
-# endif /* BIGENDIAN */
-#else /* ALIGNMENT_WORKAROUND */
+/*
+ * Per SMBIOS v2.8.0 and later, all structures assume a little-endian
+ * ordering convention.
+ */
+#if defined(ALIGNMENT_WORKAROUND) || defined(BIGENDIAN)
+#define WORD(x) (u16)((x)[0] + ((x)[1] << 8))
+#define DWORD(x) (u32)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24))
+#define QWORD(x) (U64(DWORD(x), DWORD(x + 4)))
+#else /* ALIGNMENT_WORKAROUND || BIGENDIAN */
#define WORD(x) (u16)(*(const u16 *)(x))
#define DWORD(x) (u32)(*(const u32 *)(x))
#define QWORD(x) (*(const u64 *)(x))
-#endif /* ALIGNMENT_WORKAROUND */
+#endif /* ALIGNMENT_WORKAROUND || BIGENDIAN */
#endif