From 650674bb41f2147be7eeb1d25913e45aa0dc4b39 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 5 Dec 2023 12:16:48 +0000 Subject: [PATCH] Add MBEDTLS_BSWAPxx intrinsics for IAR Signed-off-by: Dave Rodgman --- library/alignment.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/alignment.h b/library/alignment.h index 634d61046..9e1e044ec 100644 --- a/library/alignment.h +++ b/library/alignment.h @@ -180,6 +180,16 @@ inline void mbedtls_put_unaligned_uint64(void *p, uint64_t x) #define MBEDTLS_BSWAP32 __rev #endif +/* Detect IAR built-in byteswap routine */ +#if defined(__IAR_SYSTEMS_ICC__) +#if defined(__ARM_ACLE) +#include +#define MBEDTLS_BSWAP16(x) ((uint16_t) __rev16((uint32_t) (x))) +#define MBEDTLS_BSWAP32 __rev +#define MBEDTLS_BSWAP64 __revll +#endif +#endif + /* * Where compiler built-ins are not present, fall back to C code that the * compiler may be able to detect and transform into the relevant bswap or