modules: littlefs: Fix the endianness conversion functions

See full description in the upstream PR:
https://github.com/littlefs-project/littlefs/pull/742

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This commit is contained in:
Carles Cufi 2022-10-27 11:53:52 +02:00 committed by Stephanos Ioannidis
parent ae123c9bd1
commit f38c283c42

View file

@ -147,13 +147,12 @@ static inline int lfs_scmp(uint32_t a, uint32_t b)
/* Convert between 32-bit little-endian and native order */
static inline uint32_t lfs_fromle32(uint32_t a)
{
#if !defined(LFS_NO_INTRINSICS) && ( \
(defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \
#if (defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \
BYTE_ORDER == ORDER_LITTLE_ENDIAN) || \
(defined(__BYTE_ORDER) && defined(__ORDER_LITTLE_ENDIAN) && \
__BYTE_ORDER == __ORDER_LITTLE_ENDIAN) || \
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
return a;
#elif !defined(LFS_NO_INTRINSICS) && ( \
(defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && \
@ -187,13 +186,12 @@ static inline uint32_t lfs_frombe32(uint32_t a)
(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
return __builtin_bswap32(a);
#elif !defined(LFS_NO_INTRINSICS) && ( \
(defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && \
#elif (defined(BYTE_ORDER) && defined(ORDER_BIG_ENDIAN) && \
BYTE_ORDER == ORDER_BIG_ENDIAN) || \
(defined(__BYTE_ORDER) && defined(__ORDER_BIG_ENDIAN) && \
__BYTE_ORDER == __ORDER_BIG_ENDIAN) || \
(defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
return a;
#else
return (((uint8_t *)&a)[0] << 24) |