summaryrefslogtreecommitdiff
path: root/ruby.h
diff options
context:
space:
mode:
Diffstat (limited to 'ruby.h')
-rw-r--r--ruby.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/ruby.h b/ruby.h
index c406d6b07a..a399511f59 100644
--- a/ruby.h
+++ b/ruby.h
@@ -85,6 +85,24 @@ typedef unsigned long ID;
# endif
#endif
+#if HAVE_LONG_LONG
+# ifndef LLONG_MAX
+# ifdef LONG_LONG_MAX
+# define LLONG_MAX LONG_LONG_MAX
+# else
+ /* assuming 64bit(2's complement) long long */
+# define LLONG_MAX 9223372036854775807LL
+# endif
+# endif
+# ifndef LLONG_MIN
+# ifdef LONG_LONG_MIN
+# define LLONG_MIN LONG_LONG_MIN
+# else
+# define LLONG_MIN (-LLONG_MAX-1)
+# endif
+# endif
+#endif
+
#define FIXNUM_MAX (LONG_MAX>>1)
#define FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
@@ -101,6 +119,19 @@ VALUE rb_uint2inum _((unsigned long));
#define ULONG2NUM(v) UINT2NUM(v)
#define rb_uint_new(v) rb_uint2inum(v)
+#if HAVE_LONG_LONG
+VALUE rb_ll2inum _((long long));
+#define LL2NUM(v) rb_ll2inum(v)
+VALUE rb_ull2inum _((unsigned long long));
+#define ULL2NUM(v) rb_ull2inum(v)
+#endif
+
+#if SIZEOF_OFF_T > SIZEOF_LONG && HAVE_LONG_LONG
+# define OFFT2NUM(v) LL2NUM(v)
+#else
+# define OFFT2NUM(v) INT2NUM(v)
+#endif
+
#define FIX2LONG(x) RSHIFT((long)x,1)
#define FIX2ULONG(x) (((unsigned long)(x))>>1)
#define FIXNUM_P(f) (((long)(f))&FIXNUM_FLAG)
@@ -201,6 +232,18 @@ int rb_fix2int _((VALUE));
#define FIX2UINT(x) FIX2ULONG(x)
#endif
+#if HAVE_LONG_LONG
+long long rb_num2ll _((VALUE));
+unsigned long long rb_num2ull _((VALUE));
+# define NUM2LL(x) (FIXNUM_P(x)?FIX2LONG(x):rb_num2ll((VALUE)x))
+#endif
+
+#if HAVE_LONG_LONG && SIZEOF_OFF_T > SIZEOF_LONG
+# define NUM2OFFT(x) ((off_t)NUM2LL(x))
+#else
+# define NUM2OFFT(x) NUM2LONG(x)
+#endif
+
double rb_num2dbl _((VALUE));
#define NUM2DBL(x) rb_num2dbl((VALUE)(x))