[前][次][番号順一覧][スレッド一覧]

ruby-changes:46328

From: normal <ko1@a...>
Date: Sat, 22 Apr 2017 10:08:20 +0900 (JST)
Subject: [ruby-changes:46328] normal:r58442 (trunk): define PACKED_STRUCT_UNALIGNED correctly

normal	2017-04-22 10:08:15 +0900 (Sat, 22 Apr 2017)

  New Revision: 58442

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58442

  Log:
    define PACKED_STRUCT_UNALIGNED correctly
    
    Defining PACKED_STRUCT_UNALIGNED to a noop in ruby/config.h (via
    `configure') prevents the definition in include/ruby/defines.h
    from working
    
    This should have been fixed in r46914, so there's a size
    regression for some objects since Ruby 2.2+.  I do not believe
    we can backport to existing releases, either, since it can
    affect ABI.
    
    Add a test for Time objects on common x86-based platforms to
    check for future regressions.
    
    * configure.in: remove PACKED_STRUCT_UNALIGNED definition
    * test/ruby/test_time.rb (test_memsize): new test for x86

  Modified files:
    trunk/configure.in
    trunk/test/ruby/test_time.rb
Index: configure.in
===================================================================
--- configure.in	(revision 58441)
+++ configure.in	(revision 58442)
@@ -1642,13 +1642,11 @@ AC_CACHE_CHECK(packed struct attribute, https://github.com/ruby/ruby/blob/trunk/configure.in#L1642
 			PACKED_STRUCT(struct { int a; });], [],
 		[rb_cv_packed_struct=$mac; break])
     done])
-packed_struct_unaligned=x
 if test "$rb_cv_packed_struct" != no; then
     AC_DEFINE_UNQUOTED([PACKED_STRUCT(x)], [$rb_cv_packed_struct])
 else
     AC_DEFINE_UNQUOTED([PACKED_STRUCT(x)], x)
 fi
-AC_DEFINE_UNQUOTED(PACKED_STRUCT_UNALIGNED(x), $packed_struct_unaligned)
 
 AC_DEFUN([RUBY_CHECK_PRINTF_PREFIX], [
 AC_CACHE_CHECK([for printf prefix for $1], [rb_cv_pri_prefix_]AS_TR_SH($1),[
Index: test/ruby/test_time.rb
===================================================================
--- test/ruby/test_time.rb	(revision 58441)
+++ test/ruby/test_time.rb	(revision 58442)
@@ -1110,4 +1110,21 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L1110
     end.new
     assert_raise_with_message(TypeError, /Inexact/) {Time.at(x)}
   end
+
+  def test_memsize
+    # Time objects are common in some code, try to keep them small
+    skip "Time object size test" if /^(?:i.?86|x86_64)-linux/ !~ RUBY_PLATFORM
+    require 'objspace'
+    t = Time.at(0)
+    size = GC::INTERNAL_CONSTANTS[:RVALUE_SIZE]
+    case size
+    when 20 then expect = 50
+    when 40 then expect = 86
+    else
+      flunk "Unsupported RVALUE_SIZE=#{size}, update test_memsize"
+    end
+    assert_equal expect, ObjectSpace.memsize_of(t)
+  rescue LoadError => e
+    skip "failed to load objspace: #{e.message}"
+  end
 end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]