Commit 663a5c215aecaad5ca9d921271a7f1af6449ca6e
authorDoug Goldstein <cardoe@cardoe.com>
Mon, 10 Mar 2014 01:18:49 +0000 (20:18 -0500)
committerDoug Goldstein <cardoe@cardoe.com>
Mon, 10 Mar 2014 01:24:56 +0000 (20:24 -0500)
Provide likely/unlikely branch hinting macros.

simavr/sim/sim_avr.h

index 9690cf7f14a8a6732c06222e5d8851953680c3ae..07985e1a918fce087f89262cd10e4b9dc16106ba 100644 (file)
@@ -427,5 +427,27 @@ avr_pending_sleep_usec(
 #include "sim_io.h"
 #include "sim_regbit.h"
 
+#ifdef __GNUC__
+
+# ifndef likely
+#  define likely(x) __builtin_expect(!!(x), 1)
+# endif
+
+# ifndef unlikely
+#  define unlikely(x) __builtin_expect(!!(x), 0)
+# endif
+
+#else /* ! __GNUC__ */
+
+# ifndef likely
+#  define likely(x) x
+# endif
+
+# ifndef unlikely
+#  define unlikely(x) x
+# endif
+
+#endif /* __GNUC__ */
+
 #endif /*__SIM_AVR_H__*/