Ruby 3.5.0dev (2025-02-20 revision 34098b669c0cbc024cd08e686891f1dfe0a10aaf)
st_data_t.h
Go to the documentation of this file.
1#ifndef RBIMPL_ARITHMERIC_ST_DATA_T_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_ARITHMERIC_ST_DATA_T_H
28#include "ruby/internal/cast.h"
29#include "ruby/internal/value.h"
30#include "ruby/assert.h"
31#include "ruby/st.h"
32
33#define ST2FIX RB_ST2FIX
35#define RB_ST2FIX RB_ST2FIX
58static inline VALUE
59RB_ST2FIX(st_data_t i)
60{
61 SIGNED_VALUE x = RBIMPL_CAST((SIGNED_VALUE)i);
62
63 if (x >= 0) {
64 x &= RUBY_FIXNUM_MAX;
65 }
66 else {
67 x |= RUBY_FIXNUM_MIN;
68 }
69
71 unsigned long y = RBIMPL_CAST((unsigned long)x);
72 return RB_LONG2FIX(RBIMPL_CAST((long)y));
73}
74
75#endif /* RBIMPL_ARITHMETIC_ST_DATA_T_H */
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
Definition artificial.h:43
#define RBIMPL_ASSERT_OR_ASSUME(...)
This is either RUBY_ASSERT or RBIMPL_ASSUME, depending on RUBY_DEBUG.
Definition assert.h:311
Defines RBIMPL_ATTR_CONST.
#define RBIMPL_ATTR_CONST_UNLESS_DEBUG()
Enables RBIMPL_ATTR_CONST if and only if.
Definition const.h:41
RBIMPL_ATTR_CONSTEXPR.
#define RBIMPL_ATTR_CONSTEXPR_UNLESS_DEBUG(_)
Enables RBIMPL_ATTR_CONSTEXPR if and only if.
Definition constexpr.h:79
Handling of integers formerly known as Fixnums.
#define RB_FIXABLE(_)
Checks if the passed value is in range of fixnum.
Definition fixnum.h:52
#define RUBY_FIXNUM_MAX
Maximum possible value that a fixnum can represent.
Definition fixnum.h:55
#define RUBY_FIXNUM_MIN
Minimum possible value that a fixnum can represent.
Definition fixnum.h:58
Arithmetic conversion between C's long and Ruby's.
#define RB_LONG2FIX
Just another name of RB_INT2FIX.
Definition long.h:55
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:91
static VALUE RB_ST2FIX(st_data_t i)
Converts a C's st_data_t into an instance of rb_cInteger.
Definition st_data_t.h:59
Defines VALUE and ID.
intptr_t SIGNED_VALUE
A signed integer type that has the same width with VALUE.
Definition value.h:63
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40