diff --git a/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs new file mode 100644 index 0000000000..208ce1fcb6 --- /dev/null +++ b/csharp/src/Google.Protobuf/Reflection/FeatureSetDescriptor.g.cs @@ -0,0 +1,17 @@ +#region Copyright notice and license +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd +#endregion + +namespace Google.Protobuf.Reflection; + +internal sealed partial class FeatureSetDescriptor +{ + // Canonical serialized form of the edition defaults, generated by embed_edition_defaults. + private const string DefaultsBase64 = + "ChMYhAciACoMCAEQAhgCIAMoATACChMY5wciACoMCAIQARgBIAIoATABChMY6AciDAgBEAEYASACKAEwASoAIOYHKOgH"; +} diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index ca2718562a..924ea5be6c 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -60,6 +60,15 @@ Error, UINTPTR_MAX is undefined */ #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs))) +// A flexible array member may have lower alignment requirements than the struct +// overall - in that case, it can overlap with the trailing padding of the rest +// of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation +// will not take into account that overlap, and allocate more than is required. +#define UPB_SIZEOF_FLEX(type, member, count) \ + (UPB_MAX(sizeof(type), \ + (offsetof(type, member) + \ + count * (offsetof(type, member[1]) - offsetof(type, member[0]))))) + #define UPB_MAPTYPE_STRING 0 // UPB_EXPORT: always generate a public symbol. @@ -4935,7 +4944,7 @@ typedef struct { } upb_MdEnumDecoder; static size_t upb_MiniTableEnum_Size(size_t count) { - return sizeof(upb_MiniTableEnum) + count * sizeof(uint32_t); + return UPB_SIZEOF_FLEX(upb_MiniTableEnum, UPB_PRIVATE(data), count); } static upb_MiniTableEnum* _upb_MiniTable_AddEnumDataMember(upb_MdEnumDecoder* d, @@ -17297,6 +17306,7 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n, #undef UPB_SIZE #undef UPB_PTR_AT +#undef UPB_SIZEOF_FLEX #undef UPB_MAPTYPE_STRING #undef UPB_EXPORT #undef UPB_INLINE diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index dada045adf..4247c132a8 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -59,6 +59,15 @@ Error, UINTPTR_MAX is undefined */ #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs))) +// A flexible array member may have lower alignment requirements than the struct +// overall - in that case, it can overlap with the trailing padding of the rest +// of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation +// will not take into account that overlap, and allocate more than is required. +#define UPB_SIZEOF_FLEX(type, member, count) \ + (UPB_MAX(sizeof(type), \ + (offsetof(type, member) + \ + count * (offsetof(type, member[1]) - offsetof(type, member[0]))))) + #define UPB_MAPTYPE_STRING 0 // UPB_EXPORT: always generate a public symbol. @@ -15528,6 +15537,7 @@ upb_MethodDef* _upb_MethodDefs_New(upb_DefBuilder* ctx, int n, #undef UPB_SIZE #undef UPB_PTR_AT +#undef UPB_SIZEOF_FLEX #undef UPB_MAPTYPE_STRING #undef UPB_EXPORT #undef UPB_INLINE diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 0cb8b441da..af4351e444 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -60,6 +60,15 @@ Error, UINTPTR_MAX is undefined */ #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs))) +// A flexible array member may have lower alignment requirements than the struct +// overall - in that case, it can overlap with the trailing padding of the rest +// of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation +// will not take into account that overlap, and allocate more than is required. +#define UPB_SIZEOF_FLEX(type, member, count) \ + (UPB_MAX(sizeof(type), \ + (offsetof(type, member) + \ + count * (offsetof(type, member[1]) - offsetof(type, member[0]))))) + #define UPB_MAPTYPE_STRING 0 // UPB_EXPORT: always generate a public symbol. @@ -4935,7 +4944,7 @@ typedef struct { } upb_MdEnumDecoder; static size_t upb_MiniTableEnum_Size(size_t count) { - return sizeof(upb_MiniTableEnum) + count * sizeof(uint32_t); + return UPB_SIZEOF_FLEX(upb_MiniTableEnum, UPB_PRIVATE(data), count); } static upb_MiniTableEnum* _upb_MiniTable_AddEnumDataMember(upb_MdEnumDecoder* d, @@ -16784,6 +16793,7 @@ upb_ServiceDef* _upb_ServiceDefs_New(upb_DefBuilder* ctx, int n, #undef UPB_SIZE #undef UPB_PTR_AT +#undef UPB_SIZEOF_FLEX #undef UPB_MAPTYPE_STRING #undef UPB_EXPORT #undef UPB_INLINE diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index af8d4e30e5..1f6f6a05c7 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -61,6 +61,15 @@ Error, UINTPTR_MAX is undefined */ #define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs))) +// A flexible array member may have lower alignment requirements than the struct +// overall - in that case, it can overlap with the trailing padding of the rest +// of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation +// will not take into account that overlap, and allocate more than is required. +#define UPB_SIZEOF_FLEX(type, member, count) \ + (UPB_MAX(sizeof(type), \ + (offsetof(type, member) + \ + count * (offsetof(type, member[1]) - offsetof(type, member[0]))))) + #define UPB_MAPTYPE_STRING 0 // UPB_EXPORT: always generate a public symbol. @@ -15341,6 +15350,7 @@ upb_MethodDef* _upb_MethodDefs_New(upb_DefBuilder* ctx, int n, #undef UPB_SIZE #undef UPB_PTR_AT +#undef UPB_SIZEOF_FLEX #undef UPB_MAPTYPE_STRING #undef UPB_EXPORT #undef UPB_INLINE