1 #ifndef RBIMPL_INTERN_BIGNUM_H
2 #define RBIMPL_INTERN_BIGNUM_H
23 #include "ruby/internal/config.h"
219 #define rb_big2int(x) rb_big2long(x)
238 #define rb_big2uint(x) rb_big2ulong(x)
525 #define INTEGER_PACK_MSWORD_FIRST 0x01
528 #define INTEGER_PACK_LSWORD_FIRST 0x02
534 #define INTEGER_PACK_MSBYTE_FIRST 0x10
540 #define INTEGER_PACK_LSBYTE_FIRST 0x20
546 #define INTEGER_PACK_NATIVE_BYTE_ORDER 0x40
549 #define INTEGER_PACK_2COMP 0x80
552 #define INTEGER_PACK_FORCE_GENERIC_IMPLEMENTATION 0x400
558 #define INTEGER_PACK_FORCE_BIGNUM 0x100
564 #define INTEGER_PACK_NEGATIVE 0x200
567 #define INTEGER_PACK_LITTLE_ENDIAN \
568 (INTEGER_PACK_LSWORD_FIRST | \
569 INTEGER_PACK_LSBYTE_FIRST)
572 #define INTEGER_PACK_BIG_ENDIAN \
573 (INTEGER_PACK_MSWORD_FIRST | \
574 INTEGER_PACK_MSBYTE_FIRST)
679 int
rb_integer_pack(
VALUE val,
void *words,
size_t numwords,
size_t wordsize,
size_t nails,
int flags);
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" {.
int rb_integer_pack(VALUE val, void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
Exports an integer into a buffer.
VALUE rb_big_lshift(VALUE x, VALUE y)
Performs shift left.
VALUE rb_big_and(VALUE x, VALUE y)
Performs bitwise and of the passed two objects.
VALUE rb_big_or(VALUE x, VALUE y)
Performs bitwise or of the passed two objects.
VALUE rb_big_minus(VALUE x, VALUE y)
Performs subtraction of the passed two objects.
VALUE rb_big_modulo(VALUE x, VALUE y)
Performs modulo of the passed two objects.
VALUE rb_big_new(size_t len, int sign)
Allocates a bignum object.
VALUE rb_big_pow(VALUE x, VALUE y)
Raises x to the powerof y.
int rb_bigzero_p(VALUE x)
Queries if the passed bignum instance is a "bigzero".
VALUE rb_big_plus(VALUE x, VALUE y)
Performs addition of the passed two objects.
VALUE rb_str_to_inum(VALUE str, int base, int badcheck)
Identical to rb_cstr2inum(), except it takes Ruby's strings instead of C's.
VALUE rb_big_clone(VALUE num)
Duplicates the given bignum.
size_t rb_absint_size(VALUE val, int *nlz_bits_ret)
Calculates the number of bytes needed to represent the absolute value of the passed integer.
size_t rb_absint_numwords(VALUE val, size_t word_numbits, size_t *nlz_bits_ret)
Calculates the number of words needed represent the absolute value of the passed integer.
int rb_absint_singlebit_p(VALUE val)
Tests abs(val) consists only of a bit or not.
VALUE rb_integer_unpack(const void *words, size_t numwords, size_t wordsize, size_t nails, int flags)
Import an integer from a buffer.
unsigned long rb_big2ulong(VALUE x)
Converts a bignum into C's unsigned long.
VALUE rb_big_idiv(VALUE x, VALUE y)
Performs "integer division".
void rb_big_2comp(VALUE num)
Destructively modify the passed bignum into 2's complement representation.
VALUE rb_big2str(VALUE x, int base)
Generates a place-value representation of the passed integer.
VALUE rb_big_cmp(VALUE lhs, VALUE rhs)
Compares the passed two bignums.
VALUE rb_str2inum(VALUE str, int base)
Identical to rb_str_to_inum(), except the second argument controls the base and badcheck at once.
VALUE rb_dbl2big(double d)
Converts a C's double into a bignum.
VALUE rb_big_mul(VALUE x, VALUE y)
Performs multiplication of the passed two objects.
VALUE rb_big_eql(VALUE lhs, VALUE rhs)
Equality, in terms of eql?.
VALUE rb_cstr2inum(const char *str, int base)
Identical to rb_cstr_to_inum(), except the second argument controls the base and badcheck at once.
int rb_uv_to_utf8(char buf[6], unsigned long uv)
Encodes a Unicode codepoint into its UTF-8 representation.
VALUE rb_big_unpack(unsigned long *buf, long num_longs)
Constructs a (possibly very big) bignum from a series of integers.
VALUE rb_big_divmod(VALUE x, VALUE y)
Performs "divmod" operation.
VALUE rb_big_xor(VALUE x, VALUE y)
Performs exclusive or of the passed two objects.
VALUE rb_big_div(VALUE x, VALUE y)
Performs division of the passed two objects.
VALUE rb_big_norm(VALUE x)
Normalises the passed bignum.
VALUE rb_cstr_to_inum(const char *str, int base, int badcheck)
Parses C's string to convert into a Ruby's integer.
void rb_big_pack(VALUE val, unsigned long *buf, long num_longs)
Converts a bignum into a series of its parts.
VALUE rb_big_rshift(VALUE x, VALUE y)
Performs shift right.
double rb_big2dbl(VALUE x)
Converts a bignum into C's double.
long rb_big2long(VALUE x)
Converts a bignum into C's long.
void rb_big_resize(VALUE big, size_t len)
Destructively resizes the backend storage of the passed bignum.
VALUE rb_big_eq(VALUE lhs, VALUE rhs)
Equality, in terms of ==.
int len
Length of the buffer.
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
uintptr_t VALUE
Type that represents a Ruby object.