diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-06-30 19:45:32 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-06-30 19:45:32 -0700 |
commit | f813688f3ed0880e4db168c6b1baf9039d39eeee (patch) | |
tree | 09d80236615f285da576275e05dfdb73ba1b9800 /upb.h | |
parent | 9fcddef19f774c93adad136e9da25ed3b07ce76a (diff) |
Major revision to upb_parse.
Diffstat (limited to 'upb.h')
-rw-r--r-- | upb.h | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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 |