diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-18 00:01:10 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-18 00:01:10 +0000 |
commit | 94dfc14ed87f969e84cc1896be56433ede7fe369 (patch) | |
tree | 263df333b3fd1ef82d1f6327b6fe98b0ef6b1d3c /ext/socket/mkconstants.rb | |
parent | e0a459762d7e617aa5eb6496f54b3d76aefb19bb (diff) |
* ext/socket/mkconstants.rb (INTEGER2VALUE): Use LONG2FIX if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/mkconstants.rb')
-rw-r--r-- | ext/socket/mkconstants.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb index 43de36c18c..521aa95547 100644 --- a/ext/socket/mkconstants.rb +++ b/ext/socket/mkconstants.rb @@ -280,9 +280,13 @@ result = ERB.new(<<'EOS', nil, '%').result(binding) <%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %> #ifdef HAVE_LONG_LONG -#define INTEGER2VALUE(n) ((n) <= 0 ? LL2NUM(n) : ULL2NUM(n)) +#define INTEGER2VALUE(n) (0 < (n) ? \ + ((n) <= FIXNUM_MAX ? LONG2FIX(n) : ULL2NUM(n)) : \ + (FIXNUM_MIN <= (n) ? LONG2FIX(n) : LL2NUM(n))) #else -#define INTEGER2VALUE(n) ((n) <= 0 ? LONG2NUM(n) : ULONG2NUM(n)) +#define INTEGER2VALUE(n) (0 < (n) ? \ + ((n) <= FIXNUM_MAX ? LONG2FIX(n) : ULONG2NUM(n)) : \ + (FIXNUM_MIN <= (n) ? LONG2FIX(n) : LONG2NUM(n))) #endif static void |