Commits

Anonymous committed a38699f

add macros for __builtin_expect to help branch predictions

  • Participants
  • Parent commits 26077eb

Comments (0)

Files changed (2)

+2011-06-16  Sebastien Binet  <sebastien.binet@cern.ch>
+
+	* tagging CxxUtils-00-00-79
+	* add macros for __builtin_expect to help branch predictions
+	* A CxxUtils/AthUnlikelyMacros.h
+
 2011-05-31  Rolf Seuster < seuster AT cern.ch>
 	* quadruple (!) backslashs in SealDebug.cxx
 	* tagging CxxUtils-00-00-78

CxxUtils/AthUnlikelyMacros.h

+#ifndef CXXUTILS_ATHUNLIKELYMACROS_H
+#define CXXUTILS_ATHUNLIKELYMACROS_H 1
+
+/* macros modeled after http://kernelnewbies.org/FAQ/LikelyUnlikely
+ * to help the compiler into generating instructions to optimize the
+ * branch prediction.
+ */
+#if __GNUC__ >= 4
+# define ATH_LIKELY(x)       __builtin_expect(!!(x), 1)
+# define ATH_UNLIKELY(x)     __builtin_expect(!!(x), 0)
+#else
+# define ATH_LIKELY(x)   (x)
+# define ATH_UNLIKELY(x) (x)
+#endif
+
+#endif /* !CXXUTILS_ATHUNLIKELYMACROS_H */