Merge pull request #15009 from yashykt/gprlikely

Add support for GPR_LIKELY and GPR_UNLIKELY
pull/15042/head
Yash Tibrewal 7 years ago committed by GitHub
commit 344a2b2559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      include/grpc/impl/codegen/port_platform.h

@ -500,6 +500,17 @@ typedef unsigned __int64 uint64_t;
#endif /* __GPR_WINDOWS */ #endif /* __GPR_WINDOWS */
#endif /* GRPC_ALLOW_EXCEPTIONS */ #endif /* GRPC_ALLOW_EXCEPTIONS */
/* Use GPR_LIKELY only in cases where you are sure that a certain outcome is the
* most likely. Ideally, also collect performance numbers to justify the claim.
*/
#ifdef __GNUC__
#define GPR_LIKELY(x) __builtin_expect((x), 1)
#define GPR_UNLIKELY(x) __builtin_expect((x), 0)
#else /* __GNUC__ */
#define GPR_LIKELY(x) (x)
#define GPR_UNLIKELY(x) (x)
#endif /* __GNUC__ */
#ifndef __STDC_FORMAT_MACROS #ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#endif #endif

Loading…
Cancel
Save