1 #ifndef RBIMPL_ARITHMETIC_INT_H
2 #define RBIMPL_ARITHMETIC_INT_H
23 #include "ruby/internal/config.h"
37 #define RB_INT2NUM rb_int2num_inline
38 #define RB_NUM2INT rb_num2int_inline
39 #define RB_UINT2NUM rb_uint2num_inline
41 #define FIX2INT RB_FIX2INT
42 #define FIX2UINT RB_FIX2UINT
43 #define INT2NUM RB_INT2NUM
44 #define NUM2INT RB_NUM2INT
45 #define NUM2UINT RB_NUM2UINT
46 #define UINT2NUM RB_UINT2NUM
49 #define RB_FIX2INT RB_FIX2INT
50 #define RB_NUM2UINT RB_NUM2UINT
51 #define RB_FIX2UINT RB_FIX2UINT
139 if (
sizeof(int) <
sizeof(
long)) {
146 return RBIMPL_CAST((
int)ret);
162 if (
sizeof(int) ==
sizeof(
long)) {
172 return RBIMPL_CAST((
int)ret);
184 static
inline unsigned int
189 if (
sizeof(int) <
sizeof(
long)) {
196 return RBIMPL_CAST((
unsigned int)ret);
207 static
inline unsigned int
215 if (
sizeof(int) <
sizeof(
long)) {
222 return RBIMPL_CAST((
unsigned int)ret);
226 #if RBIMPL_COMPILER_IS(GCC)
228 #elif RBIMPL_HAS_WARNING("-Wtautological-constant-out-of-range-compare")
Defines RBIMPL_ATTR_ARTIFICIAL.
#define RBIMPL_ATTR_ARTIFICIAL()
Wraps (or simulates) __attribute__((artificial))
#define RBIMPL_ASSERT_OR_ASSUME(...)
This is either RUBY_ASSERT or RBIMPL_ASSUME, depending on RUBY_DEBUG.
Defines RBIMPL_COMPILER_IS.
Defines RBIMPL_ATTR_CONST.
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Handling of integers formerly known as Fixnums.
#define RB_FIXABLE(_)
Checks if the passed value is in range of fixnum.
#define RB_POSFIXABLE(_)
Checks if the passed value is in range of fixnum, assuming it is a positive number.
static unsigned int RB_FIX2UINT(VALUE x)
Converts a Fixnum into C's int.
unsigned long rb_num2uint(VALUE num)
Converts an instance of rb_cNumeric into C's unsigned long.
long rb_fix2int(VALUE num)
Identical to rb_num2int().
static int rb_num2int_inline(VALUE x)
Converts an instance of rb_cNumeric into C's int.
long rb_num2int(VALUE num)
Converts an instance of rb_cNumeric into C's long.
static VALUE rb_uint2num_inline(unsigned int v)
Converts a C's unsigned int into an instance of rb_cInteger.
static int RB_FIX2INT(VALUE x)
Converts a Fixnum into C's int.
static unsigned int RB_NUM2UINT(VALUE x)
Converts an instance of rb_cNumeric into C's unsigned int.
static VALUE rb_int2num_inline(int v)
Converts a C's int into an instance of rb_cInteger.
unsigned long rb_fix2uint(VALUE num)
Identical to rb_num2uint().
Arithmetic conversion between C's intptr_t and Ruby's.
VALUE rb_uint2big(uintptr_t i)
Converts a C's intptr_t into an instance of rb_cInteger.
VALUE rb_int2big(intptr_t i)
Converts a C's intptr_t into an instance of rb_cInteger.
Arithmetic conversion between C's long and Ruby's.
static VALUE RB_INT2FIX(long i)
Converts a C's long into an instance of rb_cInteger.
#define RB_FIX2ULONG
Just another name of rb_fix2ulong.
#define RB_NUM2ULONG
Just another name of rb_num2ulong_inline.
#define RB_FIX2LONG
Just another name of rb_fix2long.
#define RB_LONG2FIX
Just another name of RB_INT2FIX.
#define RB_NUM2LONG
Just another name of rb_num2long_inline.
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Defines enum ruby_special_consts.
static bool RB_FIXNUM_P(VALUE obj)
Checks if the given object is a so-called Fixnum.
uintptr_t VALUE
Type that represents a Ruby object.
Defines RBIMPL_WARNING_PUSH.
#define RBIMPL_WARNING_IGNORED(flag)
Suppresses a warning.
#define RBIMPL_WARNING_PUSH()
Pushes compiler warning state.
#define RBIMPL_WARNING_POP()
Pops compiler warning state.