1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-21 12:33:49 +01:00

pkg/flatbuffers: update flatbuffers to version 2.34.1

This commit is contained in:
Kasper Hjort Berthelsen 2024-05-21 15:21:32 +02:00
parent de845a69fb
commit ae35ff2146
3 changed files with 103 additions and 140 deletions

View File

@ -1,6 +1,6 @@
PKG_NAME=flatbuffers PKG_NAME=flatbuffers
PKG_URL=https://github.com/google/flatbuffers PKG_URL=https://github.com/google/flatbuffers
PKG_VERSION=9e7e8cbe9f675123dd41b7c62868acad39188cae PKG_VERSION=595bf0007ab1929570c7671f091313c8fc20644e
PKG_LICENSE=Apache2.0 PKG_LICENSE=Apache2.0
# manually set some RIOT env vars, so this Makefile can be called stand-alone # manually set some RIOT env vars, so this Makefile can be called stand-alone

View File

@ -1,7 +1,7 @@
PKG_NAME=flatbuffers PKG_NAME=flatbuffers
PKG_URL=https://github.com/google/flatbuffers PKG_URL=https://github.com/google/flatbuffers
# v2.0.0 # v24.3.25
PKG_VERSION=a9a295fecf3fbd5a4f571f53b01f63202a3e2113 PKG_VERSION=595bf0007ab1929570c7671f091313c8fc20644e
PKG_LICENSE=Apache2.0 PKG_LICENSE=Apache2.0
include $(RIOTBASE)/pkg/pkg.mk include $(RIOTBASE)/pkg/pkg.mk

View File

@ -1,39 +1,113 @@
From 6ede404cf13233bd75f6af4fc487649c7bfd27c7 Mon Sep 17 00:00:00 2001 From 89ecddee041efc5065b6ec015ac273dff5231b57 Mon Sep 17 00:00:00 2001
From: Alexandre Abadie <alexandre.abadie@inria.fr> From: Kasper Hjort Berthelsen <khjo@itu.dk>
Date: Thu, 7 Apr 2022 11:14:49 +0200 Date: Tue, 21 May 2024 15:07:30 +0200
Subject: [PATCH 1/1] Silence Wcast-align in public headers Subject: [PATCH 1/1] Silence Wcast-align in public headers
--- ---
include/flatbuffers/flatbuffers.h | 42 +++++++++++++++++++++++++++++++ include/flatbuffers/buffer.h | 3 +++
1 file changed, 42 insertions(+) include/flatbuffers/flatbuffer_builder.h | 12 ++++++++++++
include/flatbuffers/table.h | 6 ++++++
include/flatbuffers/vector_downward.h | 6 ++++++
4 files changed, 27 insertions(+)
diff --git a/include/flatbuffers/flatbuffers.h b/include/flatbuffers/flatbuffers.h diff --git a/include/flatbuffers/buffer.h b/include/flatbuffers/buffer.h
index ee34d54e..52cad4c6 100644 index 94d4f790..4f163f6e 100644
--- a/include/flatbuffers/flatbuffers.h --- a/include/flatbuffers/buffer.h
+++ b/include/flatbuffers/flatbuffers.h +++ b/include/flatbuffers/buffer.h
@@ -107,7 +107,10 @@ template<typename T> struct IndirectHelper { @@ -119,9 +119,12 @@ struct IndirectHelper<OffsetT<T>> {
typedef T mutable_return_type;
static const size_t element_stride = sizeof(T); // Then read the scalar value of the offset (which may be 32 or 64-bits) and
static return_type Read(const uint8_t *p, uoffset_t i) { // then determine the relative location from the offset location.
+#pragma GCC diagnostic push +#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align" +#pragma GCC diagnostic ignored "-Wcast-align"
return EndianScalar((reinterpret_cast<const T *>(p))[i]); return reinterpret_cast<return_type>(
+#pragma GCC diagnostic pop offset_location + ReadScalar<offset_type>(offset_location));
} }
}; +#pragma GCC diagnostic pop
template<typename T> struct IndirectHelper<Offset<T>> { static mutable_return_type Read(uint8_t *const p, const offset_type i) {
@@ -116,7 +119,10 @@ template<typename T> struct IndirectHelper<Offset<T>> { // Offsets are relative to themselves, so first update the pointer to
static const size_t element_stride = sizeof(uoffset_t); // point to the offset location.
static return_type Read(const uint8_t *p, uoffset_t i) { diff --git a/include/flatbuffers/flatbuffer_builder.h b/include/flatbuffers/flatbuffer_builder.h
p += i * sizeof(uoffset_t); index 9a2d6254..4ea23b88 100644
--- a/include/flatbuffers/flatbuffer_builder.h
+++ b/include/flatbuffers/flatbuffer_builder.h
@@ -54,7 +54,10 @@ const T *data(const std::vector<T, Alloc> &v) {
// Eventually the returned pointer gets passed down to memcpy, so
// we need it to be non-null to avoid undefined behavior.
static uint8_t t;
+#pragma GCC diagnostic push +#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align" +#pragma GCC diagnostic ignored "-Wcast-align"
return reinterpret_cast<return_type>(p + ReadScalar<uoffset_t>(p)); return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front();
+#pragma GCC diagnostic pop
}
template<typename T, typename Alloc = std::allocator<T>>
T *data(std::vector<T, Alloc> &v) {
@@ -440,7 +443,10 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
// Write the offsets into the table
for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc);
it < buf_.scratch_end(); it += sizeof(FieldLoc)) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto field_location = reinterpret_cast<FieldLoc *>(it);
+#pragma GCC diagnostic pop
const voffset_t pos =
static_cast<voffset_t>(vtable_offset_loc - field_location->off);
// If this asserts, it means you've set a field twice.
@@ -449,7 +455,10 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
WriteScalar<voffset_t>(buf_.data() + field_location->id, pos);
}
ClearOffsets();
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto vt1 = reinterpret_cast<voffset_t *>(buf_.data());
+#pragma GCC diagnostic pop
auto vt1_size = ReadScalar<voffset_t>(vt1);
auto vt_use = GetSizeRelative32BitRegion();
// See if we already have generated a vtable with this exact same
@@ -457,8 +466,11 @@ template<bool Is64Aware = false> class FlatBufferBuilderImpl {
if (dedup_vtables_) {
for (auto it = buf_.scratch_data(); it < buf_.scratch_end();
it += sizeof(uoffset_t)) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto vt_offset_ptr = reinterpret_cast<uoffset_t *>(it);
auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*vt_offset_ptr));
+#pragma GCC diagnostic pop
auto vt2_size = ReadScalar<voffset_t>(vt2);
if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue;
vt_use = *vt_offset_ptr;
diff --git a/include/flatbuffers/table.h b/include/flatbuffers/table.h
index e92d8ae8..c2400a3b 100644
--- a/include/flatbuffers/table.h
+++ b/include/flatbuffers/table.h
@@ -51,8 +51,11 @@ class Table {
P GetPointer(voffset_t field) {
auto field_offset = GetOptionalFieldOffset(field);
auto p = data_ + field_offset;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
return field_offset ? reinterpret_cast<P>(p + ReadScalar<OffsetSize>(p))
: nullptr;
+#pragma GCC diagnostic pop +#pragma GCC diagnostic pop
} }
}; template<typename P, typename OffsetSize = uoffset_t>
template<typename T> struct IndirectHelper<const T *> { P GetPointer(voffset_t field) const {
@@ -1034,12 +1040,18 @@ class vector_downward { @@ -70,7 +73,10 @@ class Table {
template<typename P> P GetStruct(voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
auto p = const_cast<uint8_t *>(data_ + field_offset);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
return field_offset ? reinterpret_cast<P>(p) : nullptr;
+#pragma GCC diagnostic pop
}
template<typename Raw, typename Face>
diff --git a/include/flatbuffers/vector_downward.h b/include/flatbuffers/vector_downward.h
index 2b5a92cf..dd869444 100644
--- a/include/flatbuffers/vector_downward.h
+++ b/include/flatbuffers/vector_downward.h
@@ -199,12 +199,18 @@ template<typename SizeT = uoffset_t> class vector_downward {
// Specialized version of push() that avoids memcpy call for small data. // Specialized version of push() that avoids memcpy call for small data.
template<typename T> void push_small(const T &little_endian_t) { template<typename T> void push_small(const T &little_endian_t) {
make_space(sizeof(T)); make_space(sizeof(T));
@ -52,117 +126,6 @@ index ee34d54e..52cad4c6 100644
scratch_ += sizeof(T); scratch_ += sizeof(T);
} }
@@ -1121,13 +1133,19 @@ const T *data(const std::vector<T, Alloc> &v) {
// Eventually the returned pointer gets passed down to memcpy, so
// we need it to be non-null to avoid undefined behavior.
static uint8_t t;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
return v.empty() ? reinterpret_cast<const T *>(&t) : &v.front();
+#pragma GCC diagnostic pop
}
template<typename T, typename Alloc> T *data(std::vector<T, Alloc> &v) {
// Eventually the returned pointer gets passed down to memcpy, so
// we need it to be non-null to avoid undefined behavior.
static uint8_t t;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
return v.empty() ? reinterpret_cast<T *>(&t) : &v.front();
+#pragma GCC diagnostic pop
}
/// @endcond
@@ -1465,7 +1483,10 @@ class FlatBufferBuilder {
// Write the offsets into the table
for (auto it = buf_.scratch_end() - num_field_loc * sizeof(FieldLoc);
it < buf_.scratch_end(); it += sizeof(FieldLoc)) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto field_location = reinterpret_cast<FieldLoc *>(it);
+#pragma GCC diagnostic pop
auto pos = static_cast<voffset_t>(vtableoffsetloc - field_location->off);
// If this asserts, it means you've set a field twice.
FLATBUFFERS_ASSERT(
@@ -1473,7 +1494,10 @@ class FlatBufferBuilder {
WriteScalar<voffset_t>(buf_.data() + field_location->id, pos);
}
ClearOffsets();
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto vt1 = reinterpret_cast<voffset_t *>(buf_.data());
+#pragma GCC diagnostic pop
auto vt1_size = ReadScalar<voffset_t>(vt1);
auto vt_use = GetSize();
// See if we already have generated a vtable with this exact same
@@ -1481,8 +1505,11 @@ class FlatBufferBuilder {
if (dedup_vtables_) {
for (auto it = buf_.scratch_data(); it < buf_.scratch_end();
it += sizeof(uoffset_t)) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto vt_offset_ptr = reinterpret_cast<uoffset_t *>(it);
auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*vt_offset_ptr));
+#pragma GCC diagnostic pop
auto vt2_size = ReadScalar<voffset_t>(vt2);
if (vt1_size != vt2_size || 0 != memcmp(vt2, vt1, vt1_size)) continue;
vt_use = *vt_offset_ptr;
@@ -2184,8 +2211,11 @@ class FlatBufferBuilder {
struct StringOffsetCompare {
StringOffsetCompare(const vector_downward &buf) : buf_(&buf) {}
bool operator()(const Offset<String> &a, const Offset<String> &b) const {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto stra = reinterpret_cast<const String *>(buf_->data_at(a.o));
auto strb = reinterpret_cast<const String *>(buf_->data_at(b.o));
+#pragma GCC diagnostic pop
return StringLessThan(stra->data(), stra->size(), strb->data(),
strb->size());
}
@@ -2578,8 +2608,11 @@ class Table {
template<typename P> P GetPointer(voffset_t field) {
auto field_offset = GetOptionalFieldOffset(field);
auto p = data_ + field_offset;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
return field_offset ? reinterpret_cast<P>(p + ReadScalar<uoffset_t>(p))
: nullptr;
+#pragma GCC diagnostic pop
}
template<typename P> P GetPointer(voffset_t field) const {
return const_cast<Table *>(this)->GetPointer<P>(field);
@@ -2588,7 +2621,10 @@ class Table {
template<typename P> P GetStruct(voffset_t field) const {
auto field_offset = GetOptionalFieldOffset(field);
auto p = const_cast<uint8_t *>(data_ + field_offset);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
return field_offset ? reinterpret_cast<P>(p) : nullptr;
+#pragma GCC diagnostic pop
}
template<typename Raw, typename Face>
@@ -2691,7 +2727,10 @@ inline flatbuffers::Optional<bool> Table::GetOptional<uint8_t, bool>(
template<typename T>
void FlatBufferBuilder::Required(Offset<T> table, voffset_t field) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto table_ptr = reinterpret_cast<const Table *>(buf_.data_at(table.o));
+#pragma GCC diagnostic pop
bool ok = table_ptr->GetOptionalFieldOffset(field) != 0;
// If this fails, the caller will show what field needs to be set.
FLATBUFFERS_ASSERT(ok);
@@ -2703,7 +2742,10 @@ void FlatBufferBuilder::Required(Offset<T> table, voffset_t field) {
/// This may be useful if you want to pass on a root and have the recipient
/// delete the buffer afterwards.
inline const uint8_t *GetBufferStartFromRootPointer(const void *root) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-align"
auto table = reinterpret_cast<const Table *>(root);
+#pragma GCC diagnostic pop
auto vtable = table->GetVTable();
// Either the vtable is before the root or after the root.
auto start = (std::min)(vtable, reinterpret_cast<const uint8_t *>(root));
-- --
2.32.0 2.34.1