From 663a5c215aecaad5ca9d921271a7f1af6449ca6e Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Sun, 9 Mar 2014 20:18:49 -0500 Subject: [PATCH] add likely/unlikely branch hint macros Provide likely/unlikely branch hinting macros. --- simavr/sim/sim_avr.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/simavr/sim/sim_avr.h b/simavr/sim/sim_avr.h index 9690cf7..07985e1 100644 --- a/simavr/sim/sim_avr.h +++ b/simavr/sim/sim_avr.h @@ -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__*/ -- 2.39.5