Auto-generate files after cl/601525709

pull/15537/head
Protobuf Team Bot 10 months ago
parent 5bded04d28
commit 1d143b5d7e
  1. 167
      php/ext/google/protobuf/php-upb.c
  2. 20
      php/ext/google/protobuf/php-upb.h
  3. 167
      ruby/ext/google/protobuf_c/ruby-upb.c
  4. 20
      ruby/ext/google/protobuf_c/ruby-upb.h

@ -113,17 +113,17 @@ Error, UINTPTR_MAX is undefined
// Macros for function attributes on compilers that support them.
#ifdef __GNUC__
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static
#define UPB_NOINLINE __attribute__((noinline))
#define UPB_NORETURN __attribute__((__noreturn__))
#define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg)))
#elif defined(_MSC_VER)
#define UPB_NOINLINE
#define UPB_FORCEINLINE
#define UPB_FORCEINLINE static
#define UPB_NORETURN __declspec(noreturn)
#define UPB_PRINTF(str, first_vararg)
#else /* !defined(__GNUC__) */
#define UPB_FORCEINLINE
#define UPB_FORCEINLINE static
#define UPB_NOINLINE
#define UPB_NORETURN
#define UPB_PRINTF(str, first_vararg)
@ -7202,8 +7202,8 @@ static _upb_DecodeLongVarintReturn _upb_Decoder_DecodeLongVarint(
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr,
uint64_t* val) {
const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr,
uint64_t* val) {
uint64_t byte = (uint8_t)*ptr;
if (UPB_LIKELY((byte & 0x80) == 0)) {
*val = byte;
@ -7217,8 +7217,8 @@ static const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr,
uint32_t* val) {
const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr,
uint32_t* val) {
uint64_t byte = (uint8_t)*ptr;
if (UPB_LIKELY((byte & 0x80) == 0)) {
*val = byte;
@ -7235,8 +7235,8 @@ static const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* upb_Decoder_DecodeSize(upb_Decoder* d, const char* ptr,
uint32_t* size) {
const char* upb_Decoder_DecodeSize(upb_Decoder* d, const char* ptr,
uint32_t* size) {
uint64_t size64;
ptr = _upb_Decoder_DecodeVarint(d, ptr, &size64);
if (size64 >= INT32_MAX ||
@ -7338,11 +7338,10 @@ static const char* _upb_Decoder_ReadString(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d,
const char* ptr,
upb_Message* submsg,
const upb_MiniTable* subl,
uint32_t expected_end_group) {
const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTable* subl,
uint32_t expected_end_group) {
if (--d->depth < 0) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_MaxDepthExceeded);
}
@ -7355,9 +7354,11 @@ static const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeSubMessage(
upb_Decoder* d, const char* ptr, upb_Message* submsg,
const upb_MiniTableSub* subs, const upb_MiniTableField* field, int size) {
const char* _upb_Decoder_DecodeSubMessage(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTableSub* subs,
const upb_MiniTableField* field,
int size) {
int saved_delta = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, size);
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
UPB_ASSERT(subl);
@ -7367,10 +7368,10 @@ static const char* _upb_Decoder_DecodeSubMessage(
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTable* subl,
uint32_t number) {
const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTable* subl,
uint32_t number) {
if (_upb_Decoder_IsDone(d, &ptr)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed);
}
@ -7380,16 +7381,16 @@ static const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeUnknownGroup(upb_Decoder* d,
const char* ptr,
uint32_t number) {
const char* _upb_Decoder_DecodeUnknownGroup(upb_Decoder* d, const char* ptr,
uint32_t number) {
return _upb_Decoder_DecodeGroup(d, ptr, NULL, NULL, number);
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeKnownGroup(
upb_Decoder* d, const char* ptr, upb_Message* submsg,
const upb_MiniTableSub* subs, const upb_MiniTableField* field) {
const char* _upb_Decoder_DecodeKnownGroup(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTableSub* subs,
const upb_MiniTableField* field) {
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
UPB_ASSERT(subl);
return _upb_Decoder_DecodeGroup(d, ptr, submsg, subl,
@ -7419,10 +7420,9 @@ static void _upb_Decoder_AddUnknownVarints(upb_Decoder* d, upb_Message* msg,
}
UPB_FORCEINLINE
static bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr,
upb_Message* msg, const upb_MiniTableEnum* e,
const upb_MiniTableField* field,
wireval* val) {
bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr, upb_Message* msg,
const upb_MiniTableEnum* e,
const upb_MiniTableField* field, wireval* val) {
const uint32_t v = val->uint32_val;
if (UPB_LIKELY(upb_MiniTableEnum_CheckValue(e, v))) return true;
@ -7456,9 +7456,10 @@ static const char* _upb_Decoder_DecodeEnumArray(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeFixedPacked(
upb_Decoder* d, const char* ptr, upb_Array* arr, wireval* val,
const upb_MiniTableField* field, int lg2) {
const char* _upb_Decoder_DecodeFixedPacked(upb_Decoder* d, const char* ptr,
upb_Array* arr, wireval* val,
const upb_MiniTableField* field,
int lg2) {
int mask = (1 << lg2) - 1;
size_t count = val->size >> lg2;
if ((val->size & mask) != 0) {
@ -7493,9 +7494,10 @@ static const char* _upb_Decoder_DecodeFixedPacked(
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeVarintPacked(
upb_Decoder* d, const char* ptr, upb_Array* arr, wireval* val,
const upb_MiniTableField* field, int lg2) {
const char* _upb_Decoder_DecodeVarintPacked(upb_Decoder* d, const char* ptr,
upb_Array* arr, wireval* val,
const upb_MiniTableField* field,
int lg2) {
int scale = 1 << lg2;
int saved_limit = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size);
char* out = UPB_PTR_AT(upb_Array_MutableDataPtr(arr),
@ -7801,9 +7803,8 @@ const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static bool _upb_Decoder_TryFastDispatch(upb_Decoder* d, const char** ptr,
upb_Message* msg,
const upb_MiniTable* m) {
bool _upb_Decoder_TryFastDispatch(upb_Decoder* d, const char** ptr,
upb_Message* msg, const upb_MiniTable* m) {
#if UPB_FASTTABLE
if (m && m->UPB_PRIVATE(table_mask) != (unsigned char)-1) {
uint16_t tag = _upb_FastDecoder_LoadTag(*ptr);
@ -8041,9 +8042,8 @@ static int _upb_Decoder_GetVarintOp(const upb_MiniTableField* field) {
}
UPB_FORCEINLINE
static void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
const upb_MiniTableField* field,
int* op) {
void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
const upb_MiniTableField* field, int* op) {
// If sub-message is not linked, treat as unknown.
if (field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension) return;
const upb_MiniTable* mt_sub =
@ -8069,9 +8069,8 @@ static void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
}
UPB_FORCEINLINE
static void _upb_Decoder_MaybeVerifyUtf8(upb_Decoder* d,
const upb_MiniTableField* field,
int* op) {
void _upb_Decoder_MaybeVerifyUtf8(upb_Decoder* d,
const upb_MiniTableField* field, int* op) {
if ((field->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsAlternate) &&
UPB_UNLIKELY(d->options & kUpb_DecodeOption_AlwaysValidateUtf8))
*op = kUpb_DecodeOp_String;
@ -8141,11 +8140,10 @@ static int _upb_Decoder_GetDelimitedOp(upb_Decoder* d, const upb_MiniTable* mt,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
const upb_MiniTable* mt,
const upb_MiniTableField* field,
int wire_type, wireval* val,
int* op) {
const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
const upb_MiniTable* mt,
const upb_MiniTableField* field,
int wire_type, wireval* val, int* op) {
static const unsigned kFixed32OkMask = (1 << kUpb_FieldType_Float) |
(1 << kUpb_FieldType_Fixed32) |
(1 << kUpb_FieldType_SFixed32);
@ -8195,10 +8193,11 @@ static const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeKnownField(
upb_Decoder* d, const char* ptr, upb_Message* msg,
const upb_MiniTable* layout, const upb_MiniTableField* field, int op,
wireval* val) {
const char* _upb_Decoder_DecodeKnownField(upb_Decoder* d, const char* ptr,
upb_Message* msg,
const upb_MiniTable* layout,
const upb_MiniTableField* field,
int op, wireval* val) {
const upb_MiniTableSub* subs = layout->UPB_PRIVATE(subs);
uint8_t mode = field->UPB_PRIVATE(mode);
@ -8515,7 +8514,7 @@ static void encode_growbuffer(upb_encstate* e, size_t bytes) {
/* Call to ensure that at least "bytes" bytes are available for writing at
* e->ptr. Returns false if the bytes could not be allocated. */
UPB_FORCEINLINE
static void encode_reserve(upb_encstate* e, size_t bytes) {
void encode_reserve(upb_encstate* e, size_t bytes) {
if ((size_t)(e->ptr - e->buf) < bytes) {
encode_growbuffer(e, bytes);
return;
@ -8554,7 +8553,7 @@ static void encode_longvarint(upb_encstate* e, uint64_t val) {
}
UPB_FORCEINLINE
static void encode_varint(upb_encstate* e, uint64_t val) {
void encode_varint(upb_encstate* e, uint64_t val) {
if (val < 128 && e->ptr != e->buf) {
--e->ptr;
*e->ptr = val;
@ -9100,7 +9099,7 @@ static const char* fastdecode_isdonefallback(UPB_PARSE_PARAMS) {
}
UPB_FORCEINLINE
static const char* fastdecode_dispatch(UPB_PARSE_PARAMS) {
const char* fastdecode_dispatch(UPB_PARSE_PARAMS) {
int overrun;
switch (upb_EpsCopyInputStream_IsDoneStatus(&d->input, ptr, &overrun)) {
case kUpb_IsDoneStatus_Done:
@ -9122,7 +9121,7 @@ static const char* fastdecode_dispatch(UPB_PARSE_PARAMS) {
}
UPB_FORCEINLINE
static bool fastdecode_checktag(uint16_t data, int tagbytes) {
bool fastdecode_checktag(uint16_t data, int tagbytes) {
if (tagbytes == 1) {
return (data & 0xff) == 0;
} else {
@ -9131,7 +9130,7 @@ static bool fastdecode_checktag(uint16_t data, int tagbytes) {
}
UPB_FORCEINLINE
static const char* fastdecode_longsize(const char* ptr, int* size) {
const char* fastdecode_longsize(const char* ptr, int* size) {
int i;
UPB_ASSERT(*size & 0x80);
*size &= 0xff;
@ -9151,7 +9150,7 @@ static const char* fastdecode_longsize(const char* ptr, int* size) {
}
UPB_FORCEINLINE
static const char* fastdecode_delimited(
const char* fastdecode_delimited(
upb_Decoder* d, const char* ptr,
upb_EpsCopyInputStream_ParseDelimitedFunc* func, void* ctx) {
ptr++;
@ -9204,8 +9203,8 @@ typedef struct {
} fastdecode_nextret;
UPB_FORCEINLINE
static void* fastdecode_resizearr(upb_Decoder* d, void* dst,
fastdecode_arr* farr, int valbytes) {
void* fastdecode_resizearr(upb_Decoder* d, void* dst, fastdecode_arr* farr,
int valbytes) {
if (UPB_UNLIKELY(dst == farr->end)) {
size_t old_capacity = farr->arr->UPB_PRIVATE(capacity);
size_t old_bytes = old_capacity * valbytes;
@ -9223,7 +9222,7 @@ static void* fastdecode_resizearr(upb_Decoder* d, void* dst,
}
UPB_FORCEINLINE
static bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
if (tagbytes == 1) {
return (uint8_t)tag == (uint8_t)data;
} else {
@ -9232,19 +9231,17 @@ static bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
}
UPB_FORCEINLINE
static void fastdecode_commitarr(void* dst, fastdecode_arr* farr,
int valbytes) {
void fastdecode_commitarr(void* dst, fastdecode_arr* farr, int valbytes) {
farr->arr->UPB_PRIVATE(size) =
(size_t)((char*)dst - (char*)upb_Array_MutableDataPtr(farr->arr)) /
valbytes;
}
UPB_FORCEINLINE
static fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
const char** ptr,
fastdecode_arr* farr,
uint64_t data, int tagbytes,
int valbytes) {
fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
const char** ptr,
fastdecode_arr* farr, uint64_t data,
int tagbytes, int valbytes) {
fastdecode_nextret ret;
dst = (char*)dst + valbytes;
@ -9266,16 +9263,15 @@ static fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
}
UPB_FORCEINLINE
static void* fastdecode_fieldmem(upb_Message* msg, uint64_t data) {
void* fastdecode_fieldmem(upb_Message* msg, uint64_t data) {
size_t ofs = data >> 48;
return (char*)msg + ofs;
}
UPB_FORCEINLINE
static void* fastdecode_getfield(upb_Decoder* d, const char* ptr,
upb_Message* msg, uint64_t* data,
uint64_t* hasbits, fastdecode_arr* farr,
int valbytes, upb_card card) {
void* fastdecode_getfield(upb_Decoder* d, const char* ptr, upb_Message* msg,
uint64_t* data, uint64_t* hasbits,
fastdecode_arr* farr, int valbytes, upb_card card) {
switch (card) {
case CARD_s: {
uint8_t hasbit_index = *data >> 24;
@ -9314,7 +9310,7 @@ static void* fastdecode_getfield(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static bool fastdecode_flippacked(uint64_t* data, int tagbytes) {
bool fastdecode_flippacked(uint64_t* data, int tagbytes) {
*data ^= (0x2 ^ 0x0); // Patch data to match packed wiretype.
return fastdecode_checktag(*data, tagbytes);
}
@ -9330,7 +9326,7 @@ static bool fastdecode_flippacked(uint64_t* data, int tagbytes) {
/* varint fields **************************************************************/
UPB_FORCEINLINE
static uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
if (valbytes == 1) {
return val != 0;
} else if (zigzag) {
@ -9346,7 +9342,7 @@ static uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
}
UPB_FORCEINLINE
static const char* fastdecode_varint64(const char* ptr, uint64_t* val) {
const char* fastdecode_varint64(const char* ptr, uint64_t* val) {
ptr++;
*val = (uint8_t)ptr[-1];
if (UPB_UNLIKELY(*val & 0x80)) {
@ -9421,8 +9417,8 @@ typedef struct {
} fastdecode_varintdata;
UPB_FORCEINLINE
static const char* fastdecode_topackedvarint(upb_EpsCopyInputStream* e,
const char* ptr, void* ctx) {
const char* fastdecode_topackedvarint(upb_EpsCopyInputStream* e,
const char* ptr, void* ctx) {
upb_Decoder* d = (upb_Decoder*)e;
fastdecode_varintdata* data = ctx;
void* dst = data->dst;
@ -9701,9 +9697,8 @@ static const char* fastdecode_longstring_noutf8(
}
UPB_FORCEINLINE
static void fastdecode_docopy(upb_Decoder* d, const char* ptr, uint32_t size,
int copy, char* data, size_t data_offset,
upb_StringView* dst) {
void fastdecode_docopy(upb_Decoder* d, const char* ptr, uint32_t size, int copy,
char* data, size_t data_offset, upb_StringView* dst) {
d->arena.UPB_PRIVATE(ptr) += copy;
dst->data = data + data_offset;
UPB_UNPOISON_MEMORY_REGION(data, copy);
@ -9934,8 +9929,8 @@ typedef struct {
} fastdecode_submsgdata;
UPB_FORCEINLINE
static const char* fastdecode_tosubmsg(upb_EpsCopyInputStream* e,
const char* ptr, void* ctx) {
const char* fastdecode_tosubmsg(upb_EpsCopyInputStream* e, const char* ptr,
void* ctx) {
upb_Decoder* d = (upb_Decoder*)e;
fastdecode_submsgdata* submsg = ctx;
ptr = fastdecode_dispatch(d, ptr, submsg->msg, submsg->table, 0, 0);

@ -112,17 +112,17 @@ Error, UINTPTR_MAX is undefined
// Macros for function attributes on compilers that support them.
#ifdef __GNUC__
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static
#define UPB_NOINLINE __attribute__((noinline))
#define UPB_NORETURN __attribute__((__noreturn__))
#define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg)))
#elif defined(_MSC_VER)
#define UPB_NOINLINE
#define UPB_FORCEINLINE
#define UPB_FORCEINLINE static
#define UPB_NORETURN __declspec(noreturn)
#define UPB_PRINTF(str, first_vararg)
#else /* !defined(__GNUC__) */
#define UPB_FORCEINLINE
#define UPB_FORCEINLINE static
#define UPB_NOINLINE
#define UPB_NORETURN
#define UPB_PRINTF(str, first_vararg)
@ -2742,7 +2742,7 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_HasExtension)(
return UPB_PRIVATE(_upb_Message_Getext)(msg, ext) != NULL;
}
static UPB_FORCEINLINE void _upb_Message_GetNonExtensionField(
UPB_FORCEINLINE void _upb_Message_GetNonExtensionField(
const struct upb_Message* msg, const upb_MiniTableField* field,
const void* default_val, void* val) {
UPB_ASSUME(!upb_MiniTableField_IsExtension(field));
@ -11788,8 +11788,8 @@ typedef struct {
const char* end; // Can read up to SlopBytes bytes beyond this.
const char* limit_ptr; // For bounds checks, = end + UPB_MIN(limit, 0)
uintptr_t aliasing;
int limit; // Submessage limit relative to end
bool error; // To distinguish between EOF and error.
int limit; // Submessage limit relative to end
bool error; // To distinguish between EOF and error.
char patch[kUpb_EpsCopyInputStream_SlopBytes * 2];
} upb_EpsCopyInputStream;
@ -12126,7 +12126,7 @@ typedef const char* upb_EpsCopyInputStream_ParseDelimitedFunc(
// fits within this buffer, calls `func` with `ctx` as a parameter, where the
// pushing and popping of limits is handled automatically and with lower cost
// than the normal PushLimit()/PopLimit() sequence.
static UPB_FORCEINLINE bool upb_EpsCopyInputStream_TryParseDelimitedFast(
UPB_FORCEINLINE bool upb_EpsCopyInputStream_TryParseDelimitedFast(
upb_EpsCopyInputStream* e, const char** ptr, int len,
upb_EpsCopyInputStream_ParseDelimitedFunc* func, void* ctx) {
if (!upb_EpsCopyInputStream_CheckSubMessageSizeAvailable(e, *ptr, len)) {
@ -13214,7 +13214,7 @@ extern "C" {
UPB_PRIVATE(_upb_WireReader_LongVarint)
UPB_PRIVATE(_upb_WireReader_ReadLongVarint)(const char* ptr, uint64_t val);
static UPB_FORCEINLINE const char* UPB_PRIVATE(_upb_WireReader_ReadVarint)(
UPB_FORCEINLINE const char* UPB_PRIVATE(_upb_WireReader_ReadVarint)(
const char* ptr, uint64_t* val, int maxlen, uint64_t maxval) {
uint64_t byte = (uint8_t)*ptr;
if (UPB_LIKELY((byte & 0x80) == 0)) {
@ -13280,8 +13280,8 @@ extern "C" {
// REQUIRES: there must be at least 10 bytes of data available at `ptr`.
// Bounds checks must be performed before calling this function, preferably
// by calling upb_EpsCopyInputStream_IsDone().
static UPB_FORCEINLINE const char* upb_WireReader_ReadTag(const char* ptr,
uint32_t* tag) {
UPB_FORCEINLINE const char* upb_WireReader_ReadTag(const char* ptr,
uint32_t* tag) {
uint64_t val;
ptr = UPB_PRIVATE(_upb_WireReader_ReadVarint)(ptr, &val, 5, UINT32_MAX);
if (!ptr) return NULL;

@ -113,17 +113,17 @@ Error, UINTPTR_MAX is undefined
// Macros for function attributes on compilers that support them.
#ifdef __GNUC__
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static
#define UPB_NOINLINE __attribute__((noinline))
#define UPB_NORETURN __attribute__((__noreturn__))
#define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg)))
#elif defined(_MSC_VER)
#define UPB_NOINLINE
#define UPB_FORCEINLINE
#define UPB_FORCEINLINE static
#define UPB_NORETURN __declspec(noreturn)
#define UPB_PRINTF(str, first_vararg)
#else /* !defined(__GNUC__) */
#define UPB_FORCEINLINE
#define UPB_FORCEINLINE static
#define UPB_NOINLINE
#define UPB_NORETURN
#define UPB_PRINTF(str, first_vararg)
@ -6716,8 +6716,8 @@ static _upb_DecodeLongVarintReturn _upb_Decoder_DecodeLongVarint(
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr,
uint64_t* val) {
const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr,
uint64_t* val) {
uint64_t byte = (uint8_t)*ptr;
if (UPB_LIKELY((byte & 0x80) == 0)) {
*val = byte;
@ -6731,8 +6731,8 @@ static const char* _upb_Decoder_DecodeVarint(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr,
uint32_t* val) {
const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr,
uint32_t* val) {
uint64_t byte = (uint8_t)*ptr;
if (UPB_LIKELY((byte & 0x80) == 0)) {
*val = byte;
@ -6749,8 +6749,8 @@ static const char* _upb_Decoder_DecodeTag(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* upb_Decoder_DecodeSize(upb_Decoder* d, const char* ptr,
uint32_t* size) {
const char* upb_Decoder_DecodeSize(upb_Decoder* d, const char* ptr,
uint32_t* size) {
uint64_t size64;
ptr = _upb_Decoder_DecodeVarint(d, ptr, &size64);
if (size64 >= INT32_MAX ||
@ -6852,11 +6852,10 @@ static const char* _upb_Decoder_ReadString(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d,
const char* ptr,
upb_Message* submsg,
const upb_MiniTable* subl,
uint32_t expected_end_group) {
const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTable* subl,
uint32_t expected_end_group) {
if (--d->depth < 0) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_MaxDepthExceeded);
}
@ -6869,9 +6868,11 @@ static const char* _upb_Decoder_RecurseSubMessage(upb_Decoder* d,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeSubMessage(
upb_Decoder* d, const char* ptr, upb_Message* submsg,
const upb_MiniTableSub* subs, const upb_MiniTableField* field, int size) {
const char* _upb_Decoder_DecodeSubMessage(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTableSub* subs,
const upb_MiniTableField* field,
int size) {
int saved_delta = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, size);
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
UPB_ASSERT(subl);
@ -6881,10 +6882,10 @@ static const char* _upb_Decoder_DecodeSubMessage(
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTable* subl,
uint32_t number) {
const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTable* subl,
uint32_t number) {
if (_upb_Decoder_IsDone(d, &ptr)) {
_upb_Decoder_ErrorJmp(d, kUpb_DecodeStatus_Malformed);
}
@ -6894,16 +6895,16 @@ static const char* _upb_Decoder_DecodeGroup(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeUnknownGroup(upb_Decoder* d,
const char* ptr,
uint32_t number) {
const char* _upb_Decoder_DecodeUnknownGroup(upb_Decoder* d, const char* ptr,
uint32_t number) {
return _upb_Decoder_DecodeGroup(d, ptr, NULL, NULL, number);
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeKnownGroup(
upb_Decoder* d, const char* ptr, upb_Message* submsg,
const upb_MiniTableSub* subs, const upb_MiniTableField* field) {
const char* _upb_Decoder_DecodeKnownGroup(upb_Decoder* d, const char* ptr,
upb_Message* submsg,
const upb_MiniTableSub* subs,
const upb_MiniTableField* field) {
const upb_MiniTable* subl = _upb_MiniTableSubs_MessageByField(subs, field);
UPB_ASSERT(subl);
return _upb_Decoder_DecodeGroup(d, ptr, submsg, subl,
@ -6933,10 +6934,9 @@ static void _upb_Decoder_AddUnknownVarints(upb_Decoder* d, upb_Message* msg,
}
UPB_FORCEINLINE
static bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr,
upb_Message* msg, const upb_MiniTableEnum* e,
const upb_MiniTableField* field,
wireval* val) {
bool _upb_Decoder_CheckEnum(upb_Decoder* d, const char* ptr, upb_Message* msg,
const upb_MiniTableEnum* e,
const upb_MiniTableField* field, wireval* val) {
const uint32_t v = val->uint32_val;
if (UPB_LIKELY(upb_MiniTableEnum_CheckValue(e, v))) return true;
@ -6970,9 +6970,10 @@ static const char* _upb_Decoder_DecodeEnumArray(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeFixedPacked(
upb_Decoder* d, const char* ptr, upb_Array* arr, wireval* val,
const upb_MiniTableField* field, int lg2) {
const char* _upb_Decoder_DecodeFixedPacked(upb_Decoder* d, const char* ptr,
upb_Array* arr, wireval* val,
const upb_MiniTableField* field,
int lg2) {
int mask = (1 << lg2) - 1;
size_t count = val->size >> lg2;
if ((val->size & mask) != 0) {
@ -7007,9 +7008,10 @@ static const char* _upb_Decoder_DecodeFixedPacked(
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeVarintPacked(
upb_Decoder* d, const char* ptr, upb_Array* arr, wireval* val,
const upb_MiniTableField* field, int lg2) {
const char* _upb_Decoder_DecodeVarintPacked(upb_Decoder* d, const char* ptr,
upb_Array* arr, wireval* val,
const upb_MiniTableField* field,
int lg2) {
int scale = 1 << lg2;
int saved_limit = upb_EpsCopyInputStream_PushLimit(&d->input, ptr, val->size);
char* out = UPB_PTR_AT(upb_Array_MutableDataPtr(arr),
@ -7315,9 +7317,8 @@ const char* _upb_Decoder_CheckRequired(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static bool _upb_Decoder_TryFastDispatch(upb_Decoder* d, const char** ptr,
upb_Message* msg,
const upb_MiniTable* m) {
bool _upb_Decoder_TryFastDispatch(upb_Decoder* d, const char** ptr,
upb_Message* msg, const upb_MiniTable* m) {
#if UPB_FASTTABLE
if (m && m->UPB_PRIVATE(table_mask) != (unsigned char)-1) {
uint16_t tag = _upb_FastDecoder_LoadTag(*ptr);
@ -7555,9 +7556,8 @@ static int _upb_Decoder_GetVarintOp(const upb_MiniTableField* field) {
}
UPB_FORCEINLINE
static void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
const upb_MiniTableField* field,
int* op) {
void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
const upb_MiniTableField* field, int* op) {
// If sub-message is not linked, treat as unknown.
if (field->UPB_PRIVATE(mode) & kUpb_LabelFlags_IsExtension) return;
const upb_MiniTable* mt_sub =
@ -7583,9 +7583,8 @@ static void _upb_Decoder_CheckUnlinked(upb_Decoder* d, const upb_MiniTable* mt,
}
UPB_FORCEINLINE
static void _upb_Decoder_MaybeVerifyUtf8(upb_Decoder* d,
const upb_MiniTableField* field,
int* op) {
void _upb_Decoder_MaybeVerifyUtf8(upb_Decoder* d,
const upb_MiniTableField* field, int* op) {
if ((field->UPB_ONLYBITS(mode) & kUpb_LabelFlags_IsAlternate) &&
UPB_UNLIKELY(d->options & kUpb_DecodeOption_AlwaysValidateUtf8))
*op = kUpb_DecodeOp_String;
@ -7655,11 +7654,10 @@ static int _upb_Decoder_GetDelimitedOp(upb_Decoder* d, const upb_MiniTable* mt,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
const upb_MiniTable* mt,
const upb_MiniTableField* field,
int wire_type, wireval* val,
int* op) {
const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
const upb_MiniTable* mt,
const upb_MiniTableField* field,
int wire_type, wireval* val, int* op) {
static const unsigned kFixed32OkMask = (1 << kUpb_FieldType_Float) |
(1 << kUpb_FieldType_Fixed32) |
(1 << kUpb_FieldType_SFixed32);
@ -7709,10 +7707,11 @@ static const char* _upb_Decoder_DecodeWireValue(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static const char* _upb_Decoder_DecodeKnownField(
upb_Decoder* d, const char* ptr, upb_Message* msg,
const upb_MiniTable* layout, const upb_MiniTableField* field, int op,
wireval* val) {
const char* _upb_Decoder_DecodeKnownField(upb_Decoder* d, const char* ptr,
upb_Message* msg,
const upb_MiniTable* layout,
const upb_MiniTableField* field,
int op, wireval* val) {
const upb_MiniTableSub* subs = layout->UPB_PRIVATE(subs);
uint8_t mode = field->UPB_PRIVATE(mode);
@ -8029,7 +8028,7 @@ static void encode_growbuffer(upb_encstate* e, size_t bytes) {
/* Call to ensure that at least "bytes" bytes are available for writing at
* e->ptr. Returns false if the bytes could not be allocated. */
UPB_FORCEINLINE
static void encode_reserve(upb_encstate* e, size_t bytes) {
void encode_reserve(upb_encstate* e, size_t bytes) {
if ((size_t)(e->ptr - e->buf) < bytes) {
encode_growbuffer(e, bytes);
return;
@ -8068,7 +8067,7 @@ static void encode_longvarint(upb_encstate* e, uint64_t val) {
}
UPB_FORCEINLINE
static void encode_varint(upb_encstate* e, uint64_t val) {
void encode_varint(upb_encstate* e, uint64_t val) {
if (val < 128 && e->ptr != e->buf) {
--e->ptr;
*e->ptr = val;
@ -8614,7 +8613,7 @@ static const char* fastdecode_isdonefallback(UPB_PARSE_PARAMS) {
}
UPB_FORCEINLINE
static const char* fastdecode_dispatch(UPB_PARSE_PARAMS) {
const char* fastdecode_dispatch(UPB_PARSE_PARAMS) {
int overrun;
switch (upb_EpsCopyInputStream_IsDoneStatus(&d->input, ptr, &overrun)) {
case kUpb_IsDoneStatus_Done:
@ -8636,7 +8635,7 @@ static const char* fastdecode_dispatch(UPB_PARSE_PARAMS) {
}
UPB_FORCEINLINE
static bool fastdecode_checktag(uint16_t data, int tagbytes) {
bool fastdecode_checktag(uint16_t data, int tagbytes) {
if (tagbytes == 1) {
return (data & 0xff) == 0;
} else {
@ -8645,7 +8644,7 @@ static bool fastdecode_checktag(uint16_t data, int tagbytes) {
}
UPB_FORCEINLINE
static const char* fastdecode_longsize(const char* ptr, int* size) {
const char* fastdecode_longsize(const char* ptr, int* size) {
int i;
UPB_ASSERT(*size & 0x80);
*size &= 0xff;
@ -8665,7 +8664,7 @@ static const char* fastdecode_longsize(const char* ptr, int* size) {
}
UPB_FORCEINLINE
static const char* fastdecode_delimited(
const char* fastdecode_delimited(
upb_Decoder* d, const char* ptr,
upb_EpsCopyInputStream_ParseDelimitedFunc* func, void* ctx) {
ptr++;
@ -8718,8 +8717,8 @@ typedef struct {
} fastdecode_nextret;
UPB_FORCEINLINE
static void* fastdecode_resizearr(upb_Decoder* d, void* dst,
fastdecode_arr* farr, int valbytes) {
void* fastdecode_resizearr(upb_Decoder* d, void* dst, fastdecode_arr* farr,
int valbytes) {
if (UPB_UNLIKELY(dst == farr->end)) {
size_t old_capacity = farr->arr->UPB_PRIVATE(capacity);
size_t old_bytes = old_capacity * valbytes;
@ -8737,7 +8736,7 @@ static void* fastdecode_resizearr(upb_Decoder* d, void* dst,
}
UPB_FORCEINLINE
static bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
if (tagbytes == 1) {
return (uint8_t)tag == (uint8_t)data;
} else {
@ -8746,19 +8745,17 @@ static bool fastdecode_tagmatch(uint32_t tag, uint64_t data, int tagbytes) {
}
UPB_FORCEINLINE
static void fastdecode_commitarr(void* dst, fastdecode_arr* farr,
int valbytes) {
void fastdecode_commitarr(void* dst, fastdecode_arr* farr, int valbytes) {
farr->arr->UPB_PRIVATE(size) =
(size_t)((char*)dst - (char*)upb_Array_MutableDataPtr(farr->arr)) /
valbytes;
}
UPB_FORCEINLINE
static fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
const char** ptr,
fastdecode_arr* farr,
uint64_t data, int tagbytes,
int valbytes) {
fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
const char** ptr,
fastdecode_arr* farr, uint64_t data,
int tagbytes, int valbytes) {
fastdecode_nextret ret;
dst = (char*)dst + valbytes;
@ -8780,16 +8777,15 @@ static fastdecode_nextret fastdecode_nextrepeated(upb_Decoder* d, void* dst,
}
UPB_FORCEINLINE
static void* fastdecode_fieldmem(upb_Message* msg, uint64_t data) {
void* fastdecode_fieldmem(upb_Message* msg, uint64_t data) {
size_t ofs = data >> 48;
return (char*)msg + ofs;
}
UPB_FORCEINLINE
static void* fastdecode_getfield(upb_Decoder* d, const char* ptr,
upb_Message* msg, uint64_t* data,
uint64_t* hasbits, fastdecode_arr* farr,
int valbytes, upb_card card) {
void* fastdecode_getfield(upb_Decoder* d, const char* ptr, upb_Message* msg,
uint64_t* data, uint64_t* hasbits,
fastdecode_arr* farr, int valbytes, upb_card card) {
switch (card) {
case CARD_s: {
uint8_t hasbit_index = *data >> 24;
@ -8828,7 +8824,7 @@ static void* fastdecode_getfield(upb_Decoder* d, const char* ptr,
}
UPB_FORCEINLINE
static bool fastdecode_flippacked(uint64_t* data, int tagbytes) {
bool fastdecode_flippacked(uint64_t* data, int tagbytes) {
*data ^= (0x2 ^ 0x0); // Patch data to match packed wiretype.
return fastdecode_checktag(*data, tagbytes);
}
@ -8844,7 +8840,7 @@ static bool fastdecode_flippacked(uint64_t* data, int tagbytes) {
/* varint fields **************************************************************/
UPB_FORCEINLINE
static uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
if (valbytes == 1) {
return val != 0;
} else if (zigzag) {
@ -8860,7 +8856,7 @@ static uint64_t fastdecode_munge(uint64_t val, int valbytes, bool zigzag) {
}
UPB_FORCEINLINE
static const char* fastdecode_varint64(const char* ptr, uint64_t* val) {
const char* fastdecode_varint64(const char* ptr, uint64_t* val) {
ptr++;
*val = (uint8_t)ptr[-1];
if (UPB_UNLIKELY(*val & 0x80)) {
@ -8935,8 +8931,8 @@ typedef struct {
} fastdecode_varintdata;
UPB_FORCEINLINE
static const char* fastdecode_topackedvarint(upb_EpsCopyInputStream* e,
const char* ptr, void* ctx) {
const char* fastdecode_topackedvarint(upb_EpsCopyInputStream* e,
const char* ptr, void* ctx) {
upb_Decoder* d = (upb_Decoder*)e;
fastdecode_varintdata* data = ctx;
void* dst = data->dst;
@ -9215,9 +9211,8 @@ static const char* fastdecode_longstring_noutf8(
}
UPB_FORCEINLINE
static void fastdecode_docopy(upb_Decoder* d, const char* ptr, uint32_t size,
int copy, char* data, size_t data_offset,
upb_StringView* dst) {
void fastdecode_docopy(upb_Decoder* d, const char* ptr, uint32_t size, int copy,
char* data, size_t data_offset, upb_StringView* dst) {
d->arena.UPB_PRIVATE(ptr) += copy;
dst->data = data + data_offset;
UPB_UNPOISON_MEMORY_REGION(data, copy);
@ -9448,8 +9443,8 @@ typedef struct {
} fastdecode_submsgdata;
UPB_FORCEINLINE
static const char* fastdecode_tosubmsg(upb_EpsCopyInputStream* e,
const char* ptr, void* ctx) {
const char* fastdecode_tosubmsg(upb_EpsCopyInputStream* e, const char* ptr,
void* ctx) {
upb_Decoder* d = (upb_Decoder*)e;
fastdecode_submsgdata* submsg = ctx;
ptr = fastdecode_dispatch(d, ptr, submsg->msg, submsg->table, 0, 0);

@ -114,17 +114,17 @@ Error, UINTPTR_MAX is undefined
// Macros for function attributes on compilers that support them.
#ifdef __GNUC__
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline))
#define UPB_FORCEINLINE __inline__ __attribute__((always_inline)) static
#define UPB_NOINLINE __attribute__((noinline))
#define UPB_NORETURN __attribute__((__noreturn__))
#define UPB_PRINTF(str, first_vararg) __attribute__((format (printf, str, first_vararg)))
#elif defined(_MSC_VER)
#define UPB_NOINLINE
#define UPB_FORCEINLINE
#define UPB_FORCEINLINE static
#define UPB_NORETURN __declspec(noreturn)
#define UPB_PRINTF(str, first_vararg)
#else /* !defined(__GNUC__) */
#define UPB_FORCEINLINE
#define UPB_FORCEINLINE static
#define UPB_NOINLINE
#define UPB_NORETURN
#define UPB_PRINTF(str, first_vararg)
@ -2744,7 +2744,7 @@ UPB_INLINE bool UPB_PRIVATE(_upb_Message_HasExtension)(
return UPB_PRIVATE(_upb_Message_Getext)(msg, ext) != NULL;
}
static UPB_FORCEINLINE void _upb_Message_GetNonExtensionField(
UPB_FORCEINLINE void _upb_Message_GetNonExtensionField(
const struct upb_Message* msg, const upb_MiniTableField* field,
const void* default_val, void* val) {
UPB_ASSUME(!upb_MiniTableField_IsExtension(field));
@ -4400,8 +4400,8 @@ typedef struct {
const char* end; // Can read up to SlopBytes bytes beyond this.
const char* limit_ptr; // For bounds checks, = end + UPB_MIN(limit, 0)
uintptr_t aliasing;
int limit; // Submessage limit relative to end
bool error; // To distinguish between EOF and error.
int limit; // Submessage limit relative to end
bool error; // To distinguish between EOF and error.
char patch[kUpb_EpsCopyInputStream_SlopBytes * 2];
} upb_EpsCopyInputStream;
@ -4738,7 +4738,7 @@ typedef const char* upb_EpsCopyInputStream_ParseDelimitedFunc(
// fits within this buffer, calls `func` with `ctx` as a parameter, where the
// pushing and popping of limits is handled automatically and with lower cost
// than the normal PushLimit()/PopLimit() sequence.
static UPB_FORCEINLINE bool upb_EpsCopyInputStream_TryParseDelimitedFast(
UPB_FORCEINLINE bool upb_EpsCopyInputStream_TryParseDelimitedFast(
upb_EpsCopyInputStream* e, const char** ptr, int len,
upb_EpsCopyInputStream_ParseDelimitedFunc* func, void* ctx) {
if (!upb_EpsCopyInputStream_CheckSubMessageSizeAvailable(e, *ptr, len)) {
@ -12986,7 +12986,7 @@ extern "C" {
UPB_PRIVATE(_upb_WireReader_LongVarint)
UPB_PRIVATE(_upb_WireReader_ReadLongVarint)(const char* ptr, uint64_t val);
static UPB_FORCEINLINE const char* UPB_PRIVATE(_upb_WireReader_ReadVarint)(
UPB_FORCEINLINE const char* UPB_PRIVATE(_upb_WireReader_ReadVarint)(
const char* ptr, uint64_t* val, int maxlen, uint64_t maxval) {
uint64_t byte = (uint8_t)*ptr;
if (UPB_LIKELY((byte & 0x80) == 0)) {
@ -13052,8 +13052,8 @@ extern "C" {
// REQUIRES: there must be at least 10 bytes of data available at `ptr`.
// Bounds checks must be performed before calling this function, preferably
// by calling upb_EpsCopyInputStream_IsDone().
static UPB_FORCEINLINE const char* upb_WireReader_ReadTag(const char* ptr,
uint32_t* tag) {
UPB_FORCEINLINE const char* upb_WireReader_ReadTag(const char* ptr,
uint32_t* tag) {
uint64_t val;
ptr = UPB_PRIVATE(_upb_WireReader_ReadVarint)(ptr, &val, 5, UINT32_MAX);
if (!ptr) return NULL;

Loading…
Cancel
Save