1#ifndef INTERNAL_FIXNUM_H
2#define INTERNAL_FIXNUM_H
19#if HAVE_LONG_LONG && SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
20# define DLONG LONG_LONG
21# define DL2NUM(x) LL2NUM(x)
22#elif defined(HAVE_INT128_T)
23# define DLONG int128_t
24# define DL2NUM(x) (RB_FIXABLE(x) ? LONG2FIX(x) : rb_int128t2big(x))
25VALUE rb_int128t2big(int128_t n);
28static inline long rb_overflowed_fix_to_int(
long x);
35static inline bool FIXNUM_POSITIVE_P(
VALUE num);
36static inline bool FIXNUM_NEGATIVE_P(
VALUE num);
37static inline bool FIXNUM_ZERO_P(
VALUE num);
40rb_overflowed_fix_to_int(
long x)
42 return (
long)((
unsigned long)(x >> 1) ^ (1L
U << (SIZEOF_LONG *
CHAR_BIT - 1)));
48#if !__has_builtin(__builtin_add_overflow)
73 if (__builtin_add_overflow((
long)x, (
long)y-1, &lz)) {
74 return rb_int2big(rb_overflowed_fix_to_int(lz));
85#if !__has_builtin(__builtin_sub_overflow)
90 if (__builtin_sub_overflow((
long)x, (
long)y-1, &lz)) {
91 return rb_int2big(rb_overflowed_fix_to_int(lz));
106 return DL2NUM((DLONG)lx * (DLONG)ly);
138 if (y > 0 ? mod < 0 : mod > 0) {
153 rb_fix_divmod_fix(x, y, &
div,
NULL);
164 rb_fix_divmod_fix(x, y,
NULL, &
mod);
VALUE rb_int2big(intptr_t n)
VALUE rb_big_mul(VALUE x, VALUE y)
#define MUL_OVERFLOW_FIXNUM_P(a, b)
Internal header absorbing C compipler differences.
Thin wrapper to ruby/config.h.
typedef long(ZCALLBACK *tell_file_func) OF((voidpf opaque
Historical shim for <limits.h>.