diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 1482db7f62..c801b22adf 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -11755,6 +11755,10 @@ upb_ServiceDef* _upb_ServiceDefs_New( } +#include +#include +#include +#include #include @@ -11805,13 +11809,13 @@ static const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr, UPB_NORETURN static void* _upb_Decoder_ErrorJmp(upb_Decoder* d, upb_DecodeStatus status) { - assert(status != kUpb_DecodeStatus_Ok); + UPB_ASSERT(status != kUpb_DecodeStatus_Ok); d->status = status; UPB_LONGJMP(d->err, 1); } const char* _upb_FastDecoder_ErrorJmp(upb_Decoder* d, int status) { - assert(status != kUpb_DecodeStatus_Ok); + UPB_ASSERT(status != kUpb_DecodeStatus_Ok); d->status = status; UPB_LONGJMP(d->err, 1); return NULL; @@ -12458,7 +12462,7 @@ UPB_NOINLINE const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr, const upb_Message* msg, const upb_MiniTable* l) { - assert(l->required_count); + UPB_ASSERT(l->required_count); if (UPB_LIKELY((d->options & kUpb_DecodeOption_CheckRequired) == 0)) { return ptr; } @@ -12724,10 +12728,10 @@ static void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt, // All other members of the oneof must be message fields that are also // unlinked. do { - assert(upb_MiniTableField_CType(oneof) == kUpb_CType_Message); + UPB_ASSERT(upb_MiniTableField_CType(oneof) == kUpb_CType_Message); const upb_MiniTableSub* oneof_sub = &mt->subs[oneof->UPB_PRIVATE(submsg_index)]; - assert(!oneof_sub); + UPB_ASSERT(!oneof_sub); } while (upb_MiniTable_NextOneofField(mt, &oneof)); } #endif // NDEBUG diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index d19291b401..00ebb53f82 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -1936,6 +1936,57 @@ upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size); #include +#ifndef UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ +#define UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ + + +#ifndef UPB_MINI_TABLE_INTERNAL_TYPES_H_ +#define UPB_MINI_TABLE_INTERNAL_TYPES_H_ + +typedef struct upb_Message_InternalData upb_Message_InternalData; + +typedef struct { + union { + upb_Message_InternalData* internal; + + // Force 8-byte alignment, since the data members may contain members that + // require 8-byte alignment. + double d; + }; +} upb_Message_Internal; + +#endif // UPB_MINI_TABLE_INTERNAL_TYPES_H_ + +// Map entries aren't actually stored for map fields, they are only used during +// parsing. For parsing, it helps a lot if all map entry messages have the same +// layout. The layout code in mini_table/decode.c will ensure that all map +// entries have this layout. +// +// Note that users can and do create map entries directly, which will also use +// this layout. +// +// NOTE: sync with wire/decode.c. +typedef struct { + // We only need 2 hasbits max, but due to alignment we'll use 8 bytes here, + // and the uint64_t helps make this clear. + uint64_t hasbits; + union { + upb_StringView str; // For str/bytes. + upb_value val; // For all other types. + } k; + union { + upb_StringView str; // For str/bytes. + upb_value val; // For all other types. + } v; +} upb_MapEntryData; + +typedef struct { + upb_Message_Internal internal; + upb_MapEntryData data; +} upb_MapEntry; + +#endif // UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ + #ifndef UPB_MESSAGE_INTERNAL_EXTENSION_H_ #define UPB_MESSAGE_INTERNAL_EXTENSION_H_ @@ -2053,50 +2104,6 @@ const upb_Message_Extension* _upb_Message_Getext( #endif /* UPB_MESSAGE_INTERNAL_EXTENSION_H_ */ -#ifndef UPB_MINI_TABLE_INTERNAL_MAP_ENTRY_DATA_H_ -#define UPB_MINI_TABLE_INTERNAL_MAP_ENTRY_DATA_H_ - -#include - - -// Map entries aren't actually stored for map fields, they are only used during -// parsing. For parsing, it helps a lot if all map entry messages have the same -// layout. The layout code in mini_table/decode.c will ensure that all map -// entries have this layout. -// -// Note that users can and do create map entries directly, which will also use -// this layout. -// -// NOTE: sync with mini_table/decode.c. -typedef struct { - // We only need 2 hasbits max, but due to alignment we'll use 8 bytes here, - // and the uint64_t helps make this clear. - uint64_t hasbits; - union { - upb_StringView str; // For str/bytes. - upb_value val; // For all other types. - } k; - union { - upb_StringView str; // For str/bytes. - upb_value val; // For all other types. - } v; -} upb_MapEntryData; - -typedef struct { - // LINT.IfChange(internal_layout) - union { - void* internal_data; - - // Force 8-byte alignment, since the data members may contain members that - // require 8-byte alignment. - double d; - }; - // LINT.ThenChange(//depot/google3/third_party/upb/upb/message/internal/message.h:internal_layout) - upb_MapEntryData data; -} upb_MapEntry; - -#endif // UPB_MINI_TABLE_INTERNAL_MAP_ENTRY_DATA_H_ - // Must be last. #ifdef __cplusplus @@ -2399,7 +2406,7 @@ extern const double kUpb_NaN; * these before the user's data. The user's upb_Message* points after the * upb_Message_Internal. */ -typedef struct { +struct upb_Message_InternalData { /* Total size of this structure, including the data that follows. * Must be aligned to 8, which is alignof(upb_Message_Extension) */ uint32_t size; @@ -2421,20 +2428,7 @@ typedef struct { uint32_t ext_begin; /* Data follows, as if there were an array: * char data[size - sizeof(upb_Message_InternalData)]; */ -} upb_Message_InternalData; - -typedef struct { - // LINT.IfChange(internal_layout) - union { - upb_Message_InternalData* internal; - - // Force 8-byte alignment, since the data members may contain members that - // require 8-byte alignment. - double d; - }; - // LINT.ThenChange(//depot/google3/third_party/upb/upb/message/internal/map_entry.h:internal_layout) - /* Message data follows. */ -} upb_Message_Internal; +}; /* Maps upb_CType -> memory size. */ extern char _upb_CTypeo_size[12]; diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index c189e1163b..f33a73b6d0 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -11274,6 +11274,10 @@ upb_ServiceDef* _upb_ServiceDefs_New( } +#include +#include +#include +#include #include @@ -11324,13 +11328,13 @@ static const char* _upb_Decoder_DecodeMessage(upb_Decoder* d, const char* ptr, UPB_NORETURN static void* _upb_Decoder_ErrorJmp(upb_Decoder* d, upb_DecodeStatus status) { - assert(status != kUpb_DecodeStatus_Ok); + UPB_ASSERT(status != kUpb_DecodeStatus_Ok); d->status = status; UPB_LONGJMP(d->err, 1); } const char* _upb_FastDecoder_ErrorJmp(upb_Decoder* d, int status) { - assert(status != kUpb_DecodeStatus_Ok); + UPB_ASSERT(status != kUpb_DecodeStatus_Ok); d->status = status; UPB_LONGJMP(d->err, 1); return NULL; @@ -11977,7 +11981,7 @@ UPB_NOINLINE const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr, const upb_Message* msg, const upb_MiniTable* l) { - assert(l->required_count); + UPB_ASSERT(l->required_count); if (UPB_LIKELY((d->options & kUpb_DecodeOption_CheckRequired) == 0)) { return ptr; } @@ -12243,10 +12247,10 @@ static void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt, // All other members of the oneof must be message fields that are also // unlinked. do { - assert(upb_MiniTableField_CType(oneof) == kUpb_CType_Message); + UPB_ASSERT(upb_MiniTableField_CType(oneof) == kUpb_CType_Message); const upb_MiniTableSub* oneof_sub = &mt->subs[oneof->UPB_PRIVATE(submsg_index)]; - assert(!oneof_sub); + UPB_ASSERT(!oneof_sub); } while (upb_MiniTable_NextOneofField(mt, &oneof)); } #endif // NDEBUG diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 854de8376a..829ddf0a04 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -1938,6 +1938,57 @@ upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size); #include +#ifndef UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ +#define UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ + + +#ifndef UPB_MINI_TABLE_INTERNAL_TYPES_H_ +#define UPB_MINI_TABLE_INTERNAL_TYPES_H_ + +typedef struct upb_Message_InternalData upb_Message_InternalData; + +typedef struct { + union { + upb_Message_InternalData* internal; + + // Force 8-byte alignment, since the data members may contain members that + // require 8-byte alignment. + double d; + }; +} upb_Message_Internal; + +#endif // UPB_MINI_TABLE_INTERNAL_TYPES_H_ + +// Map entries aren't actually stored for map fields, they are only used during +// parsing. For parsing, it helps a lot if all map entry messages have the same +// layout. The layout code in mini_table/decode.c will ensure that all map +// entries have this layout. +// +// Note that users can and do create map entries directly, which will also use +// this layout. +// +// NOTE: sync with wire/decode.c. +typedef struct { + // We only need 2 hasbits max, but due to alignment we'll use 8 bytes here, + // and the uint64_t helps make this clear. + uint64_t hasbits; + union { + upb_StringView str; // For str/bytes. + upb_value val; // For all other types. + } k; + union { + upb_StringView str; // For str/bytes. + upb_value val; // For all other types. + } v; +} upb_MapEntryData; + +typedef struct { + upb_Message_Internal internal; + upb_MapEntryData data; +} upb_MapEntry; + +#endif // UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ + #ifndef UPB_MESSAGE_INTERNAL_EXTENSION_H_ #define UPB_MESSAGE_INTERNAL_EXTENSION_H_ @@ -2055,50 +2106,6 @@ const upb_Message_Extension* _upb_Message_Getext( #endif /* UPB_MESSAGE_INTERNAL_EXTENSION_H_ */ -#ifndef UPB_MINI_TABLE_INTERNAL_MAP_ENTRY_DATA_H_ -#define UPB_MINI_TABLE_INTERNAL_MAP_ENTRY_DATA_H_ - -#include - - -// Map entries aren't actually stored for map fields, they are only used during -// parsing. For parsing, it helps a lot if all map entry messages have the same -// layout. The layout code in mini_table/decode.c will ensure that all map -// entries have this layout. -// -// Note that users can and do create map entries directly, which will also use -// this layout. -// -// NOTE: sync with mini_table/decode.c. -typedef struct { - // We only need 2 hasbits max, but due to alignment we'll use 8 bytes here, - // and the uint64_t helps make this clear. - uint64_t hasbits; - union { - upb_StringView str; // For str/bytes. - upb_value val; // For all other types. - } k; - union { - upb_StringView str; // For str/bytes. - upb_value val; // For all other types. - } v; -} upb_MapEntryData; - -typedef struct { - // LINT.IfChange(internal_layout) - union { - void* internal_data; - - // Force 8-byte alignment, since the data members may contain members that - // require 8-byte alignment. - double d; - }; - // LINT.ThenChange(//depot/google3/third_party/upb/upb/message/internal/message.h:internal_layout) - upb_MapEntryData data; -} upb_MapEntry; - -#endif // UPB_MINI_TABLE_INTERNAL_MAP_ENTRY_DATA_H_ - // Must be last. #ifdef __cplusplus @@ -2363,7 +2370,7 @@ extern const double kUpb_NaN; * these before the user's data. The user's upb_Message* points after the * upb_Message_Internal. */ -typedef struct { +struct upb_Message_InternalData { /* Total size of this structure, including the data that follows. * Must be aligned to 8, which is alignof(upb_Message_Extension) */ uint32_t size; @@ -2385,20 +2392,7 @@ typedef struct { uint32_t ext_begin; /* Data follows, as if there were an array: * char data[size - sizeof(upb_Message_InternalData)]; */ -} upb_Message_InternalData; - -typedef struct { - // LINT.IfChange(internal_layout) - union { - upb_Message_InternalData* internal; - - // Force 8-byte alignment, since the data members may contain members that - // require 8-byte alignment. - double d; - }; - // LINT.ThenChange(//depot/google3/third_party/upb/upb/message/internal/map_entry.h:internal_layout) - /* Message data follows. */ -} upb_Message_Internal; +}; /* Maps upb_CType -> memory size. */ extern char _upb_CTypeo_size[12];