Ruby  3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
long_long.h
Go to the documentation of this file.
1 #ifndef RBIMPL_ARITHMETIC_LONG_LONG_H /*-*-C++-*-vi:se ft=cpp:*/
2 #define RBIMPL_ARITHMETIC_LONG_LONG_H
23 #include "ruby/internal/value.h"
27 
28 #define RB_LL2NUM rb_ll2num_inline
29 #define RB_ULL2NUM rb_ull2num_inline
30 #define LL2NUM RB_LL2NUM
31 #define ULL2NUM RB_ULL2NUM
32 #define RB_NUM2LL rb_num2ll_inline
33 #define RB_NUM2ULL rb_num2ull_inline
34 #define NUM2LL RB_NUM2LL
35 #define NUM2ULL RB_NUM2ULL
45 
52 VALUE rb_ull2inum(unsigned LONG_LONG num);
53 
63 
72 unsigned LONG_LONG rb_num2ull(VALUE num);
74 
81 static inline VALUE
83 {
84  if (FIXABLE(n)) return LONG2FIX((long)n);
85  return rb_ll2inum(n);
86 }
87 
94 static inline VALUE
96 {
97  if (POSFIXABLE(n)) return LONG2FIX((long)n);
98  return rb_ull2inum(n);
99 }
100 
109 static inline LONG_LONG
111 {
112  if (RB_FIXNUM_P(x))
113  return RB_FIX2LONG(x);
114  else
115  return rb_num2ll(x);
116 }
117 
126 static inline unsigned LONG_LONG
128 {
129  if (RB_FIXNUM_P(x))
130  return RBIMPL_CAST((unsigned LONG_LONG)RB_FIX2LONG(x));
131  else
132  return rb_num2ull(x);
133 }
134 
135 #endif /* RBIMPL_ARITHMETIC_LONG_LONG_H */
Defines old LONG_LONG.
#define LONG_LONG
Definition: long_long.h:38
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:65
#define FIXABLE
Old name of RB_FIXABLE.
Definition: fixnum.h:25
#define LONG2FIX
Old name of RB_INT2FIX.
Definition: long.h:49
#define POSFIXABLE
Old name of RB_POSFIXABLE.
Definition: fixnum.h:29
LONG_LONG rb_num2ll(VALUE num)
Converts an instance of rb_cNumeric into C's long long.
unsigned LONG_LONG rb_num2ull(VALUE num)
Converts an instance of rb_cNumeric into C's unsigned long long.
static VALUE rb_ull2num_inline(unsigned LONG_LONG n)
Converts a C's unsigned long long into an instance of rb_cInteger.
Definition: long_long.h:95
VALUE rb_ull2inum(unsigned LONG_LONG num)
Converts a C's unsigned long long into an instance of rb_cInteger.
static VALUE rb_ll2num_inline(LONG_LONG n)
Converts a C's long long into an instance of rb_cInteger.
Definition: long_long.h:82
VALUE rb_ll2inum(LONG_LONG num)
Converts a C's long long into an instance of rb_cInteger.
static LONG_LONG rb_num2ll_inline(VALUE x)
Converts an instance of rb_cNumeric into C's long long.
Definition: long_long.h:110
static unsigned LONG_LONG rb_num2ull_inline(VALUE x)
Converts an instance of rb_cNumeric into C's unsigned long long.
Definition: long_long.h:127
#define RB_FIX2LONG
Just another name of rb_fix2long.
Definition: long.h:53
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition: defines.h:88
Defines enum ruby_special_consts.
static bool RB_FIXNUM_P(VALUE obj)
Checks if the given object is a so-called Fixnum.
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition: value.h:40