From 93ee8dea674b3935bf546665296bc328c124371f Mon Sep 17 00:00:00 2001 From: akr Date: Thu, 21 Aug 2008 20:30:06 +0000 Subject: * include/ruby/ruby.h (INT2NUM): just use a simple macro on LP64. (UINT2NUM): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/ruby.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 7c76691702..99453325b4 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -451,30 +451,35 @@ double rb_num2dbl(VALUE); VALUE rb_uint2big(VALUE); VALUE rb_int2big(SIGNED_VALUE); + +#if SIZEOF_INT < SIZEOF_VALUE +# define INT2NUM(v) INT2FIX((int)(v)) +# define UINT2NUM(v) LONG2FIX((unsigned int)(v)) +#else static inline VALUE INT2NUM(int v) { -# if SIZEOF_VALUE <= SIZEOF_INT if (!FIXABLE(v)) return rb_int2big(v); -# endif return INT2FIX(v); } -static inline VALUE -LONG2NUM(long v) -{ - if (FIXABLE(v)) return LONG2FIX(v); - return rb_int2big(v); -} + static inline VALUE UINT2NUM(unsigned int v) { -# if SIZEOF_VALUE <= SIZEOF_INT if (!POSFIXABLE(v)) return rb_uint2big(v); -# endif return LONG2FIX(v); } +#endif + +static inline VALUE +LONG2NUM(long v) +{ + if (FIXABLE(v)) return LONG2FIX(v); + return rb_int2big(v); +} + static inline VALUE ULONG2NUM(unsigned long v) { -- cgit v1.2.3