From 879ea7fce8a21359ad80e4008c41587b3e1769ae Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Thu, 28 Nov 2019 12:53:43 -0800 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/37343 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/include/swab.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/include/swab.h b/src/include/swab.h index 956cfa5532..57fe5a2e53 100644 --- a/src/include/swab.h +++ b/src/include/swab.h @@ -21,6 +21,7 @@ #include +#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 */ -- cgit v1.2.3