mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
libreplace: added likely()/unlikely() macros for gcc
These macros allow the compile to better optimise code that has a lot of if statements. I particularly want to use this for our low level generated NDR code.
This commit is contained in:
parent
44674efc81
commit
d27140ab76
@ -704,4 +704,23 @@ char *ufc_crypt(const char *key, const char *salt);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* these macros gain us a few percent of speed on gcc */
|
||||||
|
#if (__GNUC__ >= 3)
|
||||||
|
/* the strange !! is to ensure that __builtin_expect() takes either 0 or 1
|
||||||
|
as its first argument */
|
||||||
|
#ifndef likely
|
||||||
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
#endif
|
||||||
|
#ifndef unlikely
|
||||||
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifndef likely
|
||||||
|
#define likely(x) (x)
|
||||||
|
#endif
|
||||||
|
#ifndef unlikely
|
||||||
|
#define unlikely(x) (x)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _LIBREPLACE_REPLACE_H */
|
#endif /* _LIBREPLACE_REPLACE_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user