diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index c25f693ff297..6f6952d32617 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -5038,15 +5038,17 @@ typedef enum { kUpb_LayoutItemType_Max = kUpb_LayoutItemType_Field, } upb_LayoutItemType; -#define kUpb_LayoutItem_IndexSentinel ((uint16_t) - 1) +#define kUpb_LayoutItem_IndexSentinel ((uint16_t)-1) typedef struct { // Index of the corresponding field. When this is a oneof field, the field's // offset will be the index of the next field in a linked list. uint16_t field_index; uint16_t offset; - upb_FieldRep rep; - upb_LayoutItemType type; + // These two enums are stored in bytes to avoid trailing padding while + // preserving two-byte alignment. + uint8_t /* upb_FieldRep*/ rep; + uint8_t /* upb_LayoutItemType*/ type; } upb_LayoutItem; typedef struct { diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 7714e96738ce..c9a50024dc1b 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -5038,15 +5038,17 @@ typedef enum { kUpb_LayoutItemType_Max = kUpb_LayoutItemType_Field, } upb_LayoutItemType; -#define kUpb_LayoutItem_IndexSentinel ((uint16_t) - 1) +#define kUpb_LayoutItem_IndexSentinel ((uint16_t)-1) typedef struct { // Index of the corresponding field. When this is a oneof field, the field's // offset will be the index of the next field in a linked list. uint16_t field_index; uint16_t offset; - upb_FieldRep rep; - upb_LayoutItemType type; + // These two enums are stored in bytes to avoid trailing padding while + // preserving two-byte alignment. + uint8_t /* upb_FieldRep*/ rep; + uint8_t /* upb_LayoutItemType*/ type; } upb_LayoutItem; typedef struct {