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

ruby-changes:33086

From: normal <ko1@a...>
Date: Mon, 24 Feb 2014 20:10:16 +0900 (JST)
Subject: [ruby-changes:33086] normal:r45165 (trunk): time: only use packed struct on x86*

normal	2014-02-24 20:10:11 +0900 (Mon, 24 Feb 2014)

  New Revision: 45165

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45165

  Log:
    time: only use packed struct on x86*
    
    * configure.in: define PACKED_STRUCT_UNALIGNED for x86*
    * timev.h (struct vtm): use PACKED_STRUCT_UNALIGNED
    * time.c (struct time_object): ditto
      [Bug #9558] non-x86 cannot safely access unaligned addresses

  Modified files:
    trunk/ChangeLog
    trunk/configure.in
    trunk/time.c
    trunk/timev.h
Index: time.c
===================================================================
--- time.c	(revision 45164)
+++ time.c	(revision 45165)
@@ -1745,7 +1745,7 @@ struct time_object { https://github.com/ruby/ruby/blob/trunk/time.c#L1745
     struct vtm vtm;
     uint8_t gmt:3; /* 0:utc 1:localtime 2:fixoff 3:init */
     uint8_t tm_got:1;
-} PACKED_STRUCT;
+} PACKED_STRUCT_UNALIGNED;
 
 #define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj))
 #define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj))
Index: configure.in
===================================================================
--- configure.in	(revision 45164)
+++ configure.in	(revision 45165)
@@ -1277,8 +1277,12 @@ AC_CACHE_CHECK(packed struct attribute, https://github.com/ruby/ruby/blob/trunk/configure.in#L1277
   [rb_cv_packed_struct=yes], [rb_cv_packed_struct=no])])
 if test "$rb_cv_packed_struct" = yes; then
   AC_DEFINE_UNQUOTED(PACKED_STRUCT, __attribute__((packed)))
+  AS_CASE(["$target_cpu"],
+    [x86*|x?86], [AC_DEFINE_UNQUOTED(PACKED_STRUCT_UNALIGNED, PACKED_STRUCT)],
+    [AC_DEFINE_UNQUOTED(PACKED_STRUCT_UNALIGNED,)])
 else
   AC_DEFINE_UNQUOTED(PACKED_STRUCT,)
+  AC_DEFINE_UNQUOTED(PACKED_STRUCT_UNALIGNED,)
 fi
 
 AC_DEFUN([RUBY_CHECK_PRINTF_PREFIX], [
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45164)
+++ ChangeLog	(revision 45165)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Feb 24 20:05:41 2014  Eric Wong  <e@8...>
+
+	* configure.in: define PACKED_STRUCT_UNALIGNED for x86*
+	* timev.h (struct vtm): use PACKED_STRUCT_UNALIGNED
+	* time.c (struct time_object): ditto
+	  [Bug #9558] non-x86 cannot safely access unaligned addresses
+
 Mon Feb 24 18:10:02 2014  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* test/fiddle/test_function.rb: remove unused variables.
Index: timev.h
===================================================================
--- timev.h	(revision 45164)
+++ timev.h	(revision 45165)
@@ -14,7 +14,7 @@ struct vtm { https://github.com/ruby/ruby/blob/trunk/timev.h#L14
     uint8_t sec:6; /* 0..60 */
     uint8_t wday:3; /* 0:Sunday, 1:Monday, ..., 6:Saturday 7:init */
     uint8_t isdst:2; /* 0:StandardTime 1:DayLightSavingTime 3:init */
-} PACKED_STRUCT;
+} PACKED_STRUCT_UNALIGNED;
 
 #define TIME_SCALE 1000000000
 

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

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