endian: Replace explicit byte swapping with compiler builtin
gcc seems to have some stupid problem with deciding when to inline byte swapping functions (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92716). Using the compiler builtin instead seems to solve the problem. (This doesn't yet solve the issue for the read_be32()-family of functions, which we should maybe just get rid of at some point?) Change-Id: Ia2a6d8ea98987266ccc32ffaa0a7f78965fca1cd Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/37343 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
committed by
Patrick Georgi
parent
6fdf122fc3
commit
879ea7fce8
@ -21,6 +21,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(__ROMCC__) || ENV_ARMV4
|
||||
#define swab16(x) \
|
||||
((unsigned short)( \
|
||||
(((unsigned short)(x) & (unsigned short)0x00ffU) << 8) | \
|
||||
@ -43,5 +44,10 @@
|
||||
(((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
|
||||
(((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
|
||||
(((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56)))
|
||||
#else /* __ROMCC__ || ENV_ARMV4 */
|
||||
#define swab16(x) ((uint16_t)__builtin_bswap16(x))
|
||||
#define swab32(x) ((uint32_t)__builtin_bswap32(x))
|
||||
#define swab64(x) ((uint64_t)__builtin_bswap64(x))
|
||||
#endif /* !(__ROMCC__ || ENV_ARMV4) */
|
||||
|
||||
#endif /* _SWAB_H */
|
||||
|
Reference in New Issue
Block a user