Ruby: include/ruby/backward/2/assume.h Source File

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

assume.h
Go to the documentation of this file.
1#ifndef RUBY_BACKWARD2_ASSUME_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_BACKWARD2_ASSUME_H
23#include "ruby/internal/config.h"
24#include "ruby/internal/assume.h"
25#include "ruby/internal/has/builtin.h"
26
27#undef ASSUME /* Kill config.h definition */
28#undef UNREACHABLE /* Kill config.h definition */
29#define ASSUME RBIMPL_ASSUME
30#define UNREACHABLE RBIMPL_UNREACHABLE()
31#define UNREACHABLE_RETURN RBIMPL_UNREACHABLE_RETURN
32
33/* likely */
34#if RBIMPL_HAS_BUILTIN(__builtin_expect)
35# define RB_LIKELY(x) (__builtin_expect(!!(x), 1))
36# define RB_UNLIKELY(x) (__builtin_expect(!!(x), 0))
37
38#else
39# define RB_LIKELY(x) (x)
40# define RB_UNLIKELY(x) (x)
41#endif
42
43#endif /* RUBY_BACKWARD2_ASSUME_H */
config.h
Thin wrapper to ruby/config.h.
builtin.h
Defines RBIMPL_HAS_BUILTIN.
assume.h
Defines RBIMPL_ASSUME / RBIMPL_UNREACHABLE.