From b3f6daf83d8adf0040a1bf9401342c811502f690 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Thu, 11 Dec 2014 18:58:04 -0800 Subject: Amalgamated distribution (upb.c/upb.h) tool. There are a number of tweaks to get this to work: - The #include dependence graph wasn't quite complete, and I had to add a few #includes to get the tool to work. - I had to change a number of symbol names to avoid conflicts between 'static' definitions in different .c files. This could be avoided if the tool were smart enough to rename static symbols to have unique prefixes instead, but (i) this requires semantic understanding of C, and (ii) the macro-defined static functions (e.g., handlers for primitive types in several places) would probably trip this up. Verified that the resulting upb.h/upb.c compiles and doesn't have any unresolved references. --- upb/pb/decoder.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'upb/pb/decoder.c') diff --git a/upb/pb/decoder.c b/upb/pb/decoder.c index d774ebd..ec8c03f 100644 --- a/upb/pb/decoder.c +++ b/upb/pb/decoder.c @@ -402,7 +402,7 @@ static double as_double(uint64_t n) { double d; memcpy(&d, &n, 8); return d; } static float as_float(uint32_t n) { float f; memcpy(&f, &n, 4); return f; } // Pushes a frame onto the decoder stack. -static bool push(upb_pbdecoder *d, uint64_t end) { +static bool decoder_push(upb_pbdecoder *d, uint64_t end) { upb_pbdecoder_frame *fr = d->top; if (end > fr->end_ofs) { @@ -426,14 +426,14 @@ static bool pushtagdelim(upb_pbdecoder *d, uint32_t arg) { // field number) prior to hitting any enclosing submessage end, pushing our // existing delim end prevents us from continuing to parse values from a // corrupt proto that doesn't give us an END tag in time. - if (!push(d, d->top->end_ofs)) + if (!decoder_push(d, d->top->end_ofs)) return false; d->top->groupnum = arg; return true; } // Pops a frame from the decoder stack. -static void pop(upb_pbdecoder *d) { d->top--; } +static void decoder_pop(upb_pbdecoder *d) { d->top--; } NOINLINE int32_t upb_pbdecoder_checktag_slow(upb_pbdecoder *d, uint64_t expected) { @@ -493,7 +493,7 @@ have_tag: break; case UPB_WIRE_TYPE_END_GROUP: if (fieldnum == -d->top->groupnum) { - pop(d); + decoder_pop(d); } else if (fieldnum == d->top->groupnum) { return DECODE_ENDGROUP; } else { @@ -730,12 +730,12 @@ size_t upb_pbdecoder_decode(void *closure, const void *hd, const char *buf, ) VMCASE(OP_POP, assert(d->top > d->stack); - pop(d); + decoder_pop(d); ) VMCASE(OP_PUSHLENDELIM, uint32_t len; CHECK_RETURN(decode_v32(d, &len)); - CHECK_SUSPEND(push(d, offset(d) + len)); + CHECK_SUSPEND(decoder_push(d, offset(d) + len)); set_delim_end(d); ) VMCASE(OP_SETDELIM, -- cgit v1.2.3