cosmopolitan/libc/intrin/likely.h
Justine Tunney b8a6a989c0
Create ELF aliases for identical symbols
This change greatly reduces the number of modules that need to be
compiled. The only issue right now is that sometimes when viewing
symbol table entries, the aliased symbol is chosen.
2023-06-06 03:33:49 -07:00

23 lines
683 B
C

#ifndef COSMOPOLITAN_LIBC_BITS_LIKELY_H_
#define COSMOPOLITAN_LIBC_BITS_LIKELY_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#ifdef COSMO
#define LIKELY(x) __builtin_expect(!!(x), 1)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#if __GNUC__ + 0 >= 9 && !defined(__chibicc__)
#define VERY_LIKELY(x) __builtin_expect_with_probability(!!(x), 1, 0.999)
#else
#define VERY_LIKELY(x) LIKELY(x)
#endif
#if __GNUC__ + 0 >= 9 && !defined(__chibicc__)
#define VERY_UNLIKELY(x) __builtin_expect_with_probability(!!(x), 0, 0.999)
#else
#define VERY_UNLIKELY(x) UNLIKELY(x)
#endif
#endif /* COSMO */
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_BITS_LIKELY_H_ */