diff options
author | Julius Werner <jwerner@chromium.org> | 2019-11-28 12:53:43 -0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-12-06 15:08:50 +0000 |
commit | 879ea7fce8a21359ad80e4008c41587b3e1769ae (patch) | |
tree | 5c3ee9fc5d6d8e72aa164aeff1efc365e6de6ba5 /src/include | |
parent | 6fdf122fc391a894ae8ea340c58ef351be3dd5f1 (diff) | |
download | coreboot-879ea7fce8a21359ad80e4008c41587b3e1769ae.tar.xz |
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>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/swab.h | 6 |
1 files changed, 6 insertions, 0 deletions
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 <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 */ |