Skip to content

Commit

Permalink
linux/smbios: use endian.h htole16/32()
Browse files Browse the repository at this point in the history
Instead of reimplementing it ourself.

Thanks to Guillaume Mercier for the suggestion.

Improves d70f784
Refs open-mpi#637

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
(cherry picked from commit 2c16044)
  • Loading branch information
bgoglin committed Nov 23, 2023
1 parent 0e9a760 commit ca4cf68
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions hwloc/topology-linux.c
Expand Up @@ -7159,13 +7159,8 @@ static const char *dmi_memory_device_type(uint8_t code)
/* SMBIOS structures are stored in little-endian, at least since 2.8.
* Only used for memory size and extended_size so far.
*/
#if __BYTE_ORDER == __BIG_ENDIAN
#define get_smbios_uint16_t(x) (uint16_t)((x)[0] + ((x)[1] << 8))
#define get_smbios_uint32_t(x) (uint32_t)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24))
#else
#define get_smbios_uint16_t(x) (uint16_t)(*(uint16_t *)(x))
#define get_smbios_uint32_t(x) (uint32_t)(*(uint32_t *)(x))
#endif
#define get_smbios_uint16_t(x) htole16(*(uint16_t*)(x))
#define get_smbios_uint32_t(x) htole32(*(uint32_t*)(x))

static int dmi_memory_device_size(char *buffer, size_t len,
const struct hwloc_firmware_dmi_mem_device_header *header)
Expand Down

0 comments on commit ca4cf68

Please sign in to comment.