These macros are not only useful to enhance performance (if correctly
used) but make porting codes from PostgreSQL to pgpool easier since
the macros occasionally used in the code.
Discussion: [pgpool-hackers: 4599] Porting likely/unlikely
https://www.pgpool.net/pipermail/pgpool-hackers/2025-May/004600.html
} 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 */