mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
long long is a C99ism
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1836af769c
commit
91715ee53b
3 changed files with 14 additions and 2 deletions
|
@ -32,6 +32,10 @@ read_status(VALUE self)
|
|||
error = task_info(mach_task_self(), flavor,
|
||||
(task_info_t)&taskinfo, &out_count);
|
||||
if (error != KERN_SUCCESS) return Qnil;
|
||||
#ifndef ULL2NUM
|
||||
/* "long long" does not exist here, use size_t instead. */
|
||||
#define ULL2NUM SIZET2NUM
|
||||
#endif
|
||||
size = ULL2NUM(taskinfo.virtual_size);
|
||||
rss = ULL2NUM(taskinfo.resident_size);
|
||||
rb_struct_aset(self, INT2FIX(1), rss);
|
||||
|
|
|
@ -512,13 +512,19 @@ rb_fix_mod_fix(VALUE x, VALUE y)
|
|||
return mod;
|
||||
}
|
||||
|
||||
#if defined(HAVE_UINT128_T)
|
||||
#if defined(HAVE_UINT128_T) && defined(HAVE_LONG_LONG)
|
||||
# define bit_length(x) \
|
||||
(unsigned int) \
|
||||
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
||||
sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
|
||||
sizeof(x) <= SIZEOF_LONG_LONG ? SIZEOF_LONG_LONG * CHAR_BIT - nlz_long_long((unsigned LONG_LONG)(x)) : \
|
||||
SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
|
||||
#elif defined(HAVE_UINT128_T)
|
||||
# define bit_length(x) \
|
||||
(unsigned int) \
|
||||
(sizeof(x) <= SIZEOF_INT ? SIZEOF_INT * CHAR_BIT - nlz_int((unsigned int)(x)) : \
|
||||
sizeof(x) <= SIZEOF_LONG ? SIZEOF_LONG * CHAR_BIT - nlz_long((unsigned long)(x)) : \
|
||||
SIZEOF_INT128_T * CHAR_BIT - nlz_int128((uint128_t)(x)))
|
||||
#elif defined(HAVE_LONG_LONG)
|
||||
# define bit_length(x) \
|
||||
(unsigned int) \
|
||||
|
|
|
@ -428,6 +428,7 @@ class TestPack < Test::Unit::TestCase
|
|||
assert_operator(4, :<=, [1].pack("L!").bytesize)
|
||||
end
|
||||
|
||||
require 'rbconfig'
|
||||
def test_pack_unpack_qQ
|
||||
s1 = [578437695752307201, -506097522914230529].pack("q*")
|
||||
s2 = [578437695752307201, 17940646550795321087].pack("Q*")
|
||||
|
@ -437,6 +438,7 @@ class TestPack < Test::Unit::TestCase
|
|||
|
||||
# Note: q! and Q! should not work on platform which has no long long type.
|
||||
# Is there a such platform now?
|
||||
# @shyouhei: Yes. gcc -ansi is one of such platform.
|
||||
s1 = [578437695752307201, -506097522914230529].pack("q!*")
|
||||
s2 = [578437695752307201, 17940646550795321087].pack("Q!*")
|
||||
assert_equal([578437695752307201, -506097522914230529], s2.unpack("q!*"))
|
||||
|
@ -446,7 +448,7 @@ class TestPack < Test::Unit::TestCase
|
|||
assert_equal(8, [1].pack("Q").bytesize)
|
||||
assert_operator(8, :<=, [1].pack("q!").bytesize)
|
||||
assert_operator(8, :<=, [1].pack("Q!").bytesize)
|
||||
end
|
||||
end if RbConfig::CONFIG['HAVE_LONG_LONG']
|
||||
|
||||
def test_pack_unpack_jJ
|
||||
# Note: we assume that the size of intptr_t and uintptr_t equals to the size
|
||||
|
|
Loading…
Add table
Reference in a new issue