Ruby: include/ruby/internal/intern/bignum.h Source File

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

bignum.h
Go to the documentation of this file.
1#ifndef RBIMPL_INTERN_BIGNUM_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_INTERN_BIGNUM_H
23#include "ruby/internal/config.h"
24
25#ifdef STDC_HEADERS
26# include <stddef.h>
27#endif
28
29#include "ruby/internal/dllexport.h"
30#include "ruby/internal/value.h"
31#include "ruby/backward/2/long_long.h"
32
33 RBIMPL_SYMBOL_EXPORT_BEGIN()
34
35/* bignum.c */
36 VALUE rb_big_new(size_t, int);
37int rb_bigzero_p(VALUE x);
38 VALUE rb_big_clone(VALUE);
39void rb_big_2comp(VALUE);
40 VALUE rb_big_norm(VALUE);
41void rb_big_resize(VALUE big, size_t len);
42 VALUE rb_cstr_to_inum(const char*, int, int);
43 VALUE rb_str_to_inum(VALUE, int, int);
44 VALUE rb_cstr2inum(const char*, int);
45 VALUE rb_str2inum(VALUE, int);
46 VALUE rb_big2str(VALUE, int);
47long rb_big2long(VALUE);
48#define rb_big2int(x) rb_big2long(x)
49unsigned long rb_big2ulong(VALUE);
50#define rb_big2uint(x) rb_big2ulong(x)
51#if HAVE_LONG_LONG
52LONG_LONG rb_big2ll(VALUE);
53unsigned LONG_LONG rb_big2ull(VALUE);
54#endif /* HAVE_LONG_LONG */
55void rb_big_pack(VALUE val, unsigned long *buf, long num_longs);
56 VALUE rb_big_unpack(unsigned long *buf, long num_longs);
57int rb_uv_to_utf8(char[6],unsigned long);
58 VALUE rb_dbl2big(double);
59double rb_big2dbl(VALUE);
60 VALUE rb_big_cmp(VALUE, VALUE);
61 VALUE rb_big_eq(VALUE, VALUE);
62 VALUE rb_big_eql(VALUE, VALUE);
63 VALUE rb_big_plus(VALUE, VALUE);
64 VALUE rb_big_minus(VALUE, VALUE);
65 VALUE rb_big_mul(VALUE, VALUE);
66 VALUE rb_big_div(VALUE, VALUE);
67 VALUE rb_big_idiv(VALUE, VALUE);
68 VALUE rb_big_modulo(VALUE, VALUE);
69 VALUE rb_big_divmod(VALUE, VALUE);
70 VALUE rb_big_pow(VALUE, VALUE);
71 VALUE rb_big_and(VALUE, VALUE);
72 VALUE rb_big_or(VALUE, VALUE);
73 VALUE rb_big_xor(VALUE, VALUE);
74 VALUE rb_big_lshift(VALUE, VALUE);
75 VALUE rb_big_rshift(VALUE, VALUE);
76
77/* For rb_integer_pack and rb_integer_unpack: */
78/* "MS" in MSWORD and MSBYTE means "most significant" */
79/* "LS" in LSWORD and LSBYTE means "least significant" */
80#define INTEGER_PACK_MSWORD_FIRST 0x01
81#define INTEGER_PACK_LSWORD_FIRST 0x02
82#define INTEGER_PACK_MSBYTE_FIRST 0x10
83#define INTEGER_PACK_LSBYTE_FIRST 0x20
84#define INTEGER_PACK_NATIVE_BYTE_ORDER 0x40
85#define INTEGER_PACK_2COMP 0x80
86#define INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION 0x400
87/* For rb_integer_unpack: */
88#define INTEGER_PACK_FORCE_BIGNUM 0x100
89#define INTEGER_PACK_NEGATIVE 0x200
90/* Combinations: */
91#define INTEGER_PACK_LITTLE_ENDIAN \
92 (INTEGER_PACK_LSWORD_FIRST | \
93 INTEGER_PACK_LSBYTE_FIRST)
94#define INTEGER_PACK_BIG_ENDIAN \
95 (INTEGER_PACK_MSWORD_FIRST | \
96 INTEGER_PACK_MSBYTE_FIRST)
97int rb_integer_pack(VALUE val, void *words, size_t numwords, size_t wordsize, size_t nails, int flags);
98 VALUE rb_integer_unpack(const void *words, size_t numwords, size_t wordsize, size_t nails, int flags);
99size_t rb_absint_size(VALUE val, int *nlz_bits_ret);
100size_t rb_absint_numwords(VALUE val, size_t word_numbits, size_t *nlz_bits_ret);
101int rb_absint_singlebit_p(VALUE val);
102
103 RBIMPL_SYMBOL_EXPORT_END()
104
105#endif /* RBIMPL_INTERN_BIGNUM_H */
long_long.h
Defines old #LONG_LONG.
dllexport.h
Tewaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition: dllexport.h:86
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition: dllexport.h:77
len
uint8_t len
Definition: escape.c:17
config.h
Thin wrapper to ruby/config.h.
rb_integer_pack
int rb_integer_pack(VALUE val, void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
Definition: bignum.c:3553
rb_big_pow
VALUE rb_big_pow(VALUE, VALUE)
Definition: bignum.c:6241
rb_big_eql
VALUE rb_big_eql(VALUE, VALUE)
Definition: bignum.c:5541
rb_big_minus
VALUE rb_big_minus(VALUE, VALUE)
Definition: bignum.c:5850
rb_big_div
VALUE rb_big_div(VALUE, VALUE)
Definition: bignum.c:6088
rb_bigzero_p
int rb_bigzero_p(VALUE x)
Definition: bignum.c:2924
rb_big_idiv
VALUE rb_big_idiv(VALUE, VALUE)
Definition: bignum.c:6094
rb_big2long
long rb_big2long(VALUE)
Definition: bignum.c:5139
rb_big2dbl
double rb_big2dbl(VALUE)
Definition: bignum.c:5309
rb_big_norm
VALUE rb_big_norm(VALUE)
Definition: bignum.c:3158
rb_dbl2big
VALUE rb_dbl2big(double)
Definition: bignum.c:5248
rb_cstr2inum
VALUE rb_cstr2inum(const char *, int)
Definition: bignum.c:4544
rb_big_clone
VALUE rb_big_clone(VALUE)
Definition: bignum.c:3026
rb_big_xor
VALUE rb_big_xor(VALUE, VALUE)
Definition: bignum.c:6570
rb_big_lshift
VALUE rb_big_lshift(VALUE, VALUE)
Definition: bignum.c:6618
rb_big_rshift
VALUE rb_big_rshift(VALUE, VALUE)
Definition: bignum.c:6648
rb_absint_size
size_t rb_absint_size(VALUE val, int *nlz_bits_ret)
Definition: bignum.c:3253
rb_absint_numwords
size_t rb_absint_numwords(VALUE val, size_t word_numbits, size_t *nlz_bits_ret)
Definition: bignum.c:3388
rb_absint_singlebit_p
int rb_absint_singlebit_p(VALUE val)
Definition: bignum.c:3452
rb_integer_unpack
VALUE rb_integer_unpack(const void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
Definition: bignum.c:3639
rb_big_2comp
void rb_big_2comp(VALUE)
Definition: bignum.c:3055
rb_big2ulong
unsigned long rb_big2ulong(VALUE)
Definition: bignum.c:5124
rb_big_mul
VALUE rb_big_mul(VALUE, VALUE)
Definition: bignum.c:5930
rb_big_eq
VALUE rb_big_eq(VALUE, VALUE)
Definition: bignum.c:5521
rb_cstr_to_inum
VALUE rb_cstr_to_inum(const char *, int, int)
Definition: bignum.c:4016
rb_str_to_inum
VALUE rb_str_to_inum(VALUE, int, int)
Definition: bignum.c:4274
rb_big_divmod
VALUE rb_big_divmod(VALUE, VALUE)
Definition: bignum.c:6132
rb_big_unpack
VALUE rb_big_unpack(unsigned long *buf, long num_longs)
Definition: bignum.c:3229
rb_big_new
VALUE rb_big_new(size_t, int)
Definition: bignum.c:3020
rb_big_modulo
VALUE rb_big_modulo(VALUE, VALUE)
Definition: bignum.c:6100
rb_big_cmp
VALUE rb_big_cmp(VALUE, VALUE)
Definition: bignum.c:5416
rb_big_or
VALUE rb_big_or(VALUE, VALUE)
Definition: bignum.c:6476
rb_big_and
VALUE rb_big_and(VALUE, VALUE)
Definition: bignum.c:6357
rb_big_pack
void rb_big_pack(VALUE val, unsigned long *buf, long num_longs)
Definition: bignum.c:3221
rb_str2inum
VALUE rb_str2inum(VALUE, int)
Definition: bignum.c:4550
rb_big2str
VALUE rb_big2str(VALUE, int)
Definition: bignum.c:5090
rb_big_resize
void rb_big_resize(VALUE big, size_t len)
Definition: bignum.c:2994
rb_big_plus
VALUE rb_big_plus(VALUE, VALUE)
Definition: bignum.c:5821
rb_uv_to_utf8
int rb_uv_to_utf8(char[6], unsigned long)
Definition: pack.c:1660
buf
voidpf void * buf
Definition: ioapi.h:138
const
#define const
Definition: strftime.c:108
value.h
Defines VALUE and ID.
VALUE
unsigned long VALUE
Definition: value.h:38