summaryrefslogtreecommitdiff
path: root/include/ruby/ruby.h
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-14 03:54:34 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-14 03:54:34 +0000
commitb2a2ba119104b0ff2b6c20611d76de924596ca5b (patch)
tree198f6b99ec7f609a64e199a9efbc6dcb1e542b1e /include/ruby/ruby.h
parentd3437b7c1a496143c2bff2698082af143f5e1dc0 (diff)
* include/ruby/ruby.h: add NUM2SHORT(), NUM2USHORT() macros.
* numeric.c: ditto. * test/-ext-/num2int/test_num2int.rb: add testcases for NUM2SHORT(). * ext/-test-/num2int/num2int.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/ruby.h')
-rw-r--r--include/ruby/ruby.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 03b1a1d1c4..b0dec375d8 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -540,6 +540,25 @@ unsigned long rb_fix2uint(VALUE);
#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
#endif
+short rb_num2short(VALUE);
+unsigned short rb_num2ushort(VALUE);
+short rb_fix2short(VALUE);
+unsigned short rb_fix2ushort(VALUE);
+#define FIX2SHORT(x) (rb_fix2short((VALUE)(x)))
+#define NUM2SHORT_internal(x) (FIXNUM_P(x) ? FIX2SHORT(x) : rb_num2short(x))
+#ifdef __GNUC__
+# define NUM2SHORT(x) \
+ __extension__ ({VALUE num2short_x = (x); NUM2SHORT_internal(num2short_x);})
+#else /* __GNUC__ */
+static inline short
+NUM2SHORT(VALUE x)
+{
+ return NUM2SHORT_internal(x);
+}
+#endif /* __GNUC__ */
+#define NUM2USHORT(x) rb_num2ushort((VALUE)(x))
+
+
#ifdef HAVE_LONG_LONG
LONG_LONG rb_num2ll(VALUE);
unsigned LONG_LONG rb_num2ull(VALUE);