summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-24 11:10:11 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-24 11:10:11 +0000
commit131e4bec04f40f3dd020ce7fd8467c6a58105baa (patch)
tree547e5666f873bfb217ac57d8057982d1a39e8538
parentfa7b849f946c37422d27ce601582a7aa24eed0e3 (diff)
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--configure.in4
-rw-r--r--time.c2
-rw-r--r--timev.h2
4 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2601b37..7937d76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Feb 24 20:05:41 2014 Eric Wong <e@80x24.org>
+
+ * 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@gmail.com>
* test/fiddle/test_function.rb: remove unused variables.
diff --git a/configure.in b/configure.in
index 8d7bfba..aa5899b 100644
--- a/configure.in
+++ b/configure.in
@@ -1277,8 +1277,12 @@ AC_CACHE_CHECK(packed struct attribute, rb_cv_packed_struct,
[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], [
diff --git a/time.c b/time.c
index 208d5c0..acd589a 100644
--- a/time.c
+++ b/time.c
@@ -1745,7 +1745,7 @@ struct time_object {
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))
diff --git a/timev.h b/timev.h
index eda7023..bedf9a1 100644
--- a/timev.h
+++ b/timev.h
@@ -14,7 +14,7 @@ struct vtm {
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