From: Doug Goldstein Date: Mon, 10 Mar 2014 01:18:49 +0000 (-0500) Subject: add likely/unlikely branch hint macros X-Git-Tag: v1.2~10^2~2 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=663a5c215aecaad5ca9d921271a7f1af6449ca6e;p=sx%2Fsimavr.git add likely/unlikely branch hint macros Provide likely/unlikely branch hinting macros. --- 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__*/