diff options
Diffstat (limited to 'src/unlikely.h')
| -rw-r--r-- | src/unlikely.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/unlikely.h b/src/unlikely.h new file mode 100644 index 0000000..602c723 --- /dev/null +++ b/src/unlikely.h @@ -0,0 +1,14 @@ +#ifndef INPLA_UNLIKELY_H +#define INPLA_UNLIKELY_H + +#if defined(__GNUC__) || defined(__clang__) + // GCC と Clang の場合は、極限まで最適化! + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else + // それ以外のコンパイラ(MSVCなど)では、ただの素通り(無害化) + #define likely(x) (x) + #define unlikely(x) (x) +#endif + +#endif |
