summaryrefslogtreecommitdiff
path: root/include/ruby/defines.h
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-15 02:35:17 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-15 02:35:17 +0000
commit21429b1488faf58b6683eef2c9c24e00796a32ae (patch)
treefb40e9ac8dc96491b6a2e3fefc221384784974c9 /include/ruby/defines.h
parentf089a52865bd82a327fe9ef460cecdb812dcb56c (diff)
__alignof__ to take alignment of a type
C11 and C++11 has this feature so why not use it when available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/defines.h')
-rw-r--r--include/ruby/defines.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index da2ba24109..322df4c6d2 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -380,6 +380,16 @@ void rb_ia64_flushrs(void);
#define RUBY_ALIGNAS(x) y
#endif
+#ifdef RUBY_ALIGNOF
+/* OK, take that definition */
+#elif defined(__cplusplus) && (__cplusplus >= 201103L)
+#define RUBY_ALIGNOF alignof
+#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+#define RUBY_ALIGNOF _Alignof
+#else
+#define RUBY_ALIGNOF(x) ((size_t)offsetof(struct { char f1; type f2; }, f2))
+#endif
+
RUBY_SYMBOL_EXPORT_END
#if defined(__cplusplus)