xref: /OK3568_Linux_fs/buildroot/package/wampcc/0001-Add-RISC-V-endian-detection.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From e94589ed36c4a311355efc46ba3f76523c546057 Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
3Date: Wed, 7 Aug 2019 16:17:16 +0200
4Subject: [PATCH] Add RISC-V endian detection
5
63rdparty/msgpack-c/include/msgpack/predef/other/endian.h (which comes
7from Boost) two ways of detecting the endianess:
8
9 (1) It includes <endian.h> if BOOST_LIB_C_GNU is defined, and then
10     use __BYTE_ORDER to decide the endianness.
11
12 (2) Otherwise, if (1) was not possible for some reason, it uses
13     architecture defines to decide the endianness.
14
15(1) works perfectly fine with glibc toolchains, because
16BOOST_LIB_C_GNU is defined, but it doesn't work with musl. Due to
17this, <endian.h> is not included, __BYTE_ORDER is not defined, and
18method (1) does not work, causing build failures on musl toolchains
19that don't have explicit handling by architecture name (method 2).
20
21So this commit fixes RISC-V musl build by adding support for the
22__riscv architecture define, to determine that the endianness is
23little endian.
24
25Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
26---
27 3rdparty/msgpack-c/include/msgpack/predef/other/endian.h | 3 ++-
28 1 file changed, 2 insertions(+), 1 deletion(-)
29
30diff --git a/3rdparty/msgpack-c/include/msgpack/predef/other/endian.h b/3rdparty/msgpack-c/include/msgpack/predef/other/endian.h
31index 3c609fa..63a5722 100644
32--- a/3rdparty/msgpack-c/include/msgpack/predef/other/endian.h
33+++ b/3rdparty/msgpack-c/include/msgpack/predef/other/endian.h
34@@ -127,7 +127,8 @@ information and acquired knowledge:
35         defined(__AARCH64EL__) || \
36         defined(_MIPSEL) || \
37         defined(__MIPSEL) || \
38-        defined(__MIPSEL__)
39+        defined(__MIPSEL__) || \
40+        defined(__riscv)
41 #       undef MSGPACK_ENDIAN_LITTLE_BYTE
42 #       define MSGPACK_ENDIAN_LITTLE_BYTE MSGPACK_VERSION_NUMBER_AVAILABLE
43 #   endif
44--
452.21.0
46
47