Ruby: include/ruby/internal/arithmetic/long_long.h Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

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"
24#include "ruby/internal/dllexport.h"
25#include "ruby/internal/special_consts.h"
26#include "ruby/backward/2/long_long.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
37 RBIMPL_SYMBOL_EXPORT_BEGIN()
44 VALUE rb_ll2inum(LONG_LONG num);
45
52 VALUE rb_ull2inum(unsigned LONG_LONG num);
53
62 LONG_LONG rb_num2ll(VALUE num);
63
72 unsigned LONG_LONG rb_num2ull(VALUE num);
73 RBIMPL_SYMBOL_EXPORT_END()
74
81static inline VALUE
82rb_ll2num_inline(LONG_LONG n)
83{
84 if (FIXABLE(n)) return LONG2FIX((long)n);
85 return rb_ll2inum(n);
86}
87
94static inline VALUE
95rb_ull2num_inline(unsigned LONG_LONG n)
96{
97 if (POSFIXABLE(n)) return LONG2FIX((long)n);
98 return rb_ull2inum(n);
99}
100
109static inline LONG_LONG
110rb_num2ll_inline(VALUE x)
111{
112 if (RB_FIXNUM_P(x))
113 return RB_FIX2LONG(x);
114 else
115 return rb_num2ll(x);
116}
117
126static inline unsigned LONG_LONG
127rb_num2ull_inline(VALUE x)
128{
129 if (RB_FIXNUM_P(x))
130 return RB_FIX2LONG(x);
131 else
132 return rb_num2ull(x);
133}
134
135#endif /* RBIMPL_ARITHMETIC_LONG_LONG_H */
long_long.h
Defines old LONG_LONG.
LONG_LONG
#define LONG_LONG
Definition long_long.h:38
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:106
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:97
FIXABLE
#define FIXABLE
Old name of RB_FIXABLE.
Definition fixnum.h:25
LONG2FIX
#define LONG2FIX
Old name of RB_INT2FIX.
Definition long.h:49
POSFIXABLE
#define POSFIXABLE
Old name of RB_POSFIXABLE.
Definition fixnum.h:29
rb_num2ll
LONG_LONG rb_num2ll(VALUE num)
Converts an instance of rb_cNumeric into C's long long.
rb_num2ull
unsigned LONG_LONG rb_num2ull(VALUE num)
Converts an instance of rb_cNumeric into C's unsigned long long.
rb_ull2num_inline
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
rb_ull2inum
VALUE rb_ull2inum(unsigned LONG_LONG num)
Converts a C's unsigned long long into an instance of rb_cInteger.
rb_ll2num_inline
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
rb_ll2inum
VALUE rb_ll2inum(LONG_LONG num)
Converts a C's long long into an instance of rb_cInteger.
rb_num2ll_inline
static LONG_LONG rb_num2ll_inline(VALUE x)
Converts an instance of rb_cNumeric into C's long long.
Definition long_long.h:110
rb_num2ull_inline
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
RB_FIX2LONG
#define RB_FIX2LONG
Just another name of rb_fix2long.
Definition long.h:53
special_consts.h
Defines enum ruby_special_consts.
RB_FIXNUM_P
static bool RB_FIXNUM_P(VALUE obj)
Checks if the given object is a so-called Fixnum.
Definition special_consts.h:247
value.h
Defines VALUE and ID.
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40