summaryrefslogtreecommitdiff
path: root/eval_intern.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-30 14:48:45 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-30 14:48:45 (GMT)
commit2b582b7ca689277e63e901272b1112d19b8a914d (patch)
tree8c1d084130a3fa64a9048221777828b39c2ed0eb /eval_intern.h
parentf9d5843fd92d1cbc41eef8f2bcf54ad23326f01d (diff)
UNALIGNED_MEMBER_ACCESS
* eval_intern.h (UNALIGNED_MEMBER_ACCESS): suppress address-of-packed-member warnings by clang 4.0. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_intern.h')
-rw-r--r--eval_intern.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/eval_intern.h b/eval_intern.h
index fb28a31..6105461 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -157,6 +157,22 @@ LONG WINAPI rb_w32_stack_overflow_handler(struct _EXCEPTION_POINTERS *);
# define VAR_NOCLOBBERED(var) var
#endif
+#if defined(USE_UNALIGNED_MEMBER_ACCESS) && USE_UNALIGNED_MEMBER_ACCESS
+# define UNALIGNED_MEMBER_ACCESS(expr) __extension__({ \
+ _Pragma("GCC diagnostic push"); \
+ _Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\""); \
+ typeof(expr) unaligned_member_access_result = (expr); \
+ _Pragma("GCC diagnostic pop"); \
+ unaligned_member_access_result; \
+})
+#else
+# define UNALIGNED_MEMBER_ACCESS(expr) expr
+#endif
+#define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
+
+#undef RB_OBJ_WRITE
+#define RB_OBJ_WRITE(a, slot, b) UNALIGNED_MEMBER_ACCESS(rb_obj_write((VALUE)(a), (VALUE *)(slot), (VALUE)(b), __FILE__, __LINE__))
+
/* clear th->ec.tag->state, and return the value */
static inline int
rb_threadptr_tag_state(rb_thread_t *th)