summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-devtools
diff options
context:
space:
mode:
Diffstat (limited to 'meta-oe/recipes-devtools')
-rw-r--r--meta-oe/recipes-devtools/flatbuffers/files/0001-flatbuffers-Move-EndianSwap-template-to-flatbuffers-.patch113
-rw-r--r--meta-oe/recipes-devtools/flatbuffers/files/0002-use-__builtin_bswap16-when-building-with-clang.patch30
-rw-r--r--meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.7.1.bb6
3 files changed, 147 insertions, 2 deletions
diff --git a/meta-oe/recipes-devtools/flatbuffers/files/0001-flatbuffers-Move-EndianSwap-template-to-flatbuffers-.patch b/meta-oe/recipes-devtools/flatbuffers/files/0001-flatbuffers-Move-EndianSwap-template-to-flatbuffers-.patch
new file mode 100644
index 000000000..d736f012b
--- /dev/null
+++ b/meta-oe/recipes-devtools/flatbuffers/files/0001-flatbuffers-Move-EndianSwap-template-to-flatbuffers-.patch
@@ -0,0 +1,113 @@
1From a614d8e20fa9e4fd16b699d581ddac2956c120f5 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 19 Sep 2017 10:04:02 -0700
4Subject: [PATCH 1/2] flatbuffers: Move EndianSwap template to
5 flatbuffers/base.h
6
7Clang complains
8call to function 'EndianSwap' that is neither visible in the template definition nor found by argument-dependent lookup
9 return EndianSwap(t);
10
11This seems to be due to limitation of two-phase lookup of dependent names in template definitions
12
13Its not being found using associated namespaces therefore
14it has to be made visible at the template definition site as well
15
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18Upstream-Status: Submitted
19
20 include/flatbuffers/base.h | 33 +++++++++++++++++++++++++++++++++
21 include/flatbuffers/flatbuffers.h | 32 --------------------------------
22 2 files changed, 33 insertions(+), 32 deletions(-)
23
24diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h
25index f051755..c73fb2d 100644
26--- a/include/flatbuffers/base.h
27+++ b/include/flatbuffers/base.h
28@@ -150,6 +150,39 @@ typedef uintmax_t largest_scalar_t;
29 // We support aligning the contents of buffers up to this size.
30 #define FLATBUFFERS_MAX_ALIGNMENT 16
31
32+template<typename T> T EndianSwap(T t) {
33+ #if defined(_MSC_VER)
34+ #define FLATBUFFERS_BYTESWAP16 _byteswap_ushort
35+ #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong
36+ #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64
37+ #else
38+ #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408
39+ // __builtin_bswap16 was missing prior to GCC 4.8.
40+ #define FLATBUFFERS_BYTESWAP16(x) \
41+ static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16))
42+ #else
43+ #define FLATBUFFERS_BYTESWAP16 __builtin_bswap16
44+ #endif
45+ #define FLATBUFFERS_BYTESWAP32 __builtin_bswap32
46+ #define FLATBUFFERS_BYTESWAP64 __builtin_bswap64
47+ #endif
48+ if (sizeof(T) == 1) { // Compile-time if-then's.
49+ return t;
50+ } else if (sizeof(T) == 2) {
51+ auto r = FLATBUFFERS_BYTESWAP16(*reinterpret_cast<uint16_t *>(&t));
52+ return *reinterpret_cast<T *>(&r);
53+ } else if (sizeof(T) == 4) {
54+ auto r = FLATBUFFERS_BYTESWAP32(*reinterpret_cast<uint32_t *>(&t));
55+ return *reinterpret_cast<T *>(&r);
56+ } else if (sizeof(T) == 8) {
57+ auto r = FLATBUFFERS_BYTESWAP64(*reinterpret_cast<uint64_t *>(&t));
58+ return *reinterpret_cast<T *>(&r);
59+ } else {
60+ assert(0);
61+ }
62+}
63+
64+
65 template<typename T> T EndianScalar(T t) {
66 #if FLATBUFFERS_LITTLEENDIAN
67 return t;
68diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h
69index 9216cf4..f749dcb 100644
70--- a/include/flatbuffers/flatbuffers.h
71+++ b/include/flatbuffers/flatbuffers.h
72@@ -37,38 +37,6 @@ inline void EndianCheck() {
73 (void)endiantest;
74 }
75
76-template<typename T> T EndianSwap(T t) {
77- #if defined(_MSC_VER)
78- #define FLATBUFFERS_BYTESWAP16 _byteswap_ushort
79- #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong
80- #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64
81- #else
82- #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408
83- // __builtin_bswap16 was missing prior to GCC 4.8.
84- #define FLATBUFFERS_BYTESWAP16(x) \
85- static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16))
86- #else
87- #define FLATBUFFERS_BYTESWAP16 __builtin_bswap16
88- #endif
89- #define FLATBUFFERS_BYTESWAP32 __builtin_bswap32
90- #define FLATBUFFERS_BYTESWAP64 __builtin_bswap64
91- #endif
92- if (sizeof(T) == 1) { // Compile-time if-then's.
93- return t;
94- } else if (sizeof(T) == 2) {
95- auto r = FLATBUFFERS_BYTESWAP16(*reinterpret_cast<uint16_t *>(&t));
96- return *reinterpret_cast<T *>(&r);
97- } else if (sizeof(T) == 4) {
98- auto r = FLATBUFFERS_BYTESWAP32(*reinterpret_cast<uint32_t *>(&t));
99- return *reinterpret_cast<T *>(&r);
100- } else if (sizeof(T) == 8) {
101- auto r = FLATBUFFERS_BYTESWAP64(*reinterpret_cast<uint64_t *>(&t));
102- return *reinterpret_cast<T *>(&r);
103- } else {
104- assert(0);
105- }
106-}
107-
108 template<typename T> FLATBUFFERS_CONSTEXPR size_t AlignOf() {
109 #ifdef _MSC_VER
110 return __alignof(T);
111--
1122.14.1
113
diff --git a/meta-oe/recipes-devtools/flatbuffers/files/0002-use-__builtin_bswap16-when-building-with-clang.patch b/meta-oe/recipes-devtools/flatbuffers/files/0002-use-__builtin_bswap16-when-building-with-clang.patch
new file mode 100644
index 000000000..460159f27
--- /dev/null
+++ b/meta-oe/recipes-devtools/flatbuffers/files/0002-use-__builtin_bswap16-when-building-with-clang.patch
@@ -0,0 +1,30 @@
1From 626fe5e043de25e970ebdf061b88c646fa689113 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 19 Sep 2017 10:09:31 -0700
4Subject: [PATCH 2/2] use __builtin_bswap16 when building with clang
5
6clang pretends to be gcc 4.2.0 and therefore the code does
7not use __builtin_bswap16 but tries to synthesize it
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11Upstream-Status: Submitted
12 include/flatbuffers/base.h | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h
16index c73fb2d..13e8fac 100644
17--- a/include/flatbuffers/base.h
18+++ b/include/flatbuffers/base.h
19@@ -156,7 +156,7 @@ template<typename T> T EndianSwap(T t) {
20 #define FLATBUFFERS_BYTESWAP32 _byteswap_ulong
21 #define FLATBUFFERS_BYTESWAP64 _byteswap_uint64
22 #else
23- #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408
24+ #if defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ < 408 && !defined(__clang__)
25 // __builtin_bswap16 was missing prior to GCC 4.8.
26 #define FLATBUFFERS_BYTESWAP16(x) \
27 static_cast<uint16_t>(__builtin_bswap32(static_cast<uint32_t>(x) << 16))
28--
292.14.1
30
diff --git a/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.7.1.bb b/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.7.1.bb
index be0bef21d..a8df44485 100644
--- a/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.7.1.bb
+++ b/meta-oe/recipes-devtools/flatbuffers/flatbuffers_1.7.1.bb
@@ -13,8 +13,10 @@ LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=a873c5645c184d51e0f9b34e1d7cf559"
13SRCREV = "25a15950f5a24d7217689739ed8f6dac64912d62" 13SRCREV = "25a15950f5a24d7217689739ed8f6dac64912d62"
14 14
15SRC_URI = "git://github.com/google/flatbuffers.git \ 15SRC_URI = "git://github.com/google/flatbuffers.git \
16 file://0001-correct-version-for-so-lib.patch \ 16 file://0001-correct-version-for-so-lib.patch \
17" 17 file://0001-flatbuffers-Move-EndianSwap-template-to-flatbuffers-.patch \
18 file://0002-use-__builtin_bswap16-when-building-with-clang.patch \
19 "
18 20
19# Make sure C++11 is used, required for example for GCC 4.9 21# Make sure C++11 is used, required for example for GCC 4.9
20CXXFLAGS += "-std=c++11" 22CXXFLAGS += "-std=c++11"