diff --git a/src/include/pool_type.h b/src/include/pool_type.h index 43f29a595..d7cdf936a 100644 --- a/src/include/pool_type.h +++ b/src/include/pool_type.h @@ -500,4 +500,19 @@ typedef void (*pg_on_exit_callback) (int code, Datum arg); } while (0) +/* + * Hints to the compiler about the likelihood of a branch. Both likely() and + * unlikely() return the boolean value of the contained expression. + * + * These should only be used sparingly, in very hot code paths. It's very easy + * to mis-estimate likelihoods. + */ +#if __GNUC__ >= 3 +#define likely(x) __builtin_expect((x) != 0, 1) +#define unlikely(x) __builtin_expect((x) != 0, 0) +#else +#define likely(x) ((x) != 0) +#define unlikely(x) ((x) != 0) +#endif + #endif /* POOL_TYPE_H */