From f813688f3ed0880e4db168c6b1baf9039d39eeee Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 30 Jun 2009 19:45:32 -0700 Subject: Major revision to upb_parse. --- upb.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'upb.h') diff --git a/upb.h b/upb.h index 3281a0e..39ca0de 100644 --- a/upb.h +++ b/upb.h @@ -16,6 +16,15 @@ extern "C" { #endif +/* Branch prediction hints for GCC. */ +#ifdef __GNUC__ +#define likely(x) __builtin_expect((x),1) +#define unlikely(x) __builtin_expect((x),0) +#else +#define likely(x) (x) +#define unlikely(x) (x) +#endif + /* inline if possible, emit standalone code if required. */ #define INLINE static inline @@ -113,6 +122,9 @@ typedef enum upb_status { // The input byte stream ended in the middle of a record. UPB_STATUS_NEED_MORE_DATA = 1, + // The user value callback opted to stop parsing. + UPB_STATUS_USER_CANCELLED = 2, + // A varint did not terminate before hitting 64 bits. UPB_ERROR_UNTERMINATED_VARINT = -1, @@ -126,9 +138,16 @@ typedef enum upb_status { UPB_ERROR_OVERFLOW = -4, // An "end group" tag was encountered in an inappropriate place. - UPB_ERROR_SPURIOUS_END_GROUP = -5 + UPB_ERROR_SPURIOUS_END_GROUP = -5, + + UPB_ERROR_ILLEGAL = -6 } upb_status_t; +#define UPB_CHECK(func) do { \ + upb_status_t status = func; \ + if(status != UPB_STATUS_OK) return status; \ + } while (0) + #ifdef __cplusplus } /* extern "C" */ #endif -- cgit v1.2.3