From 21429b1488faf58b6683eef2c9c24e00796a32ae Mon Sep 17 00:00:00 2001 From: shyouhei Date: Mon, 15 Jan 2018 02:35:17 +0000 Subject: __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 --- include/ruby/defines.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') 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) -- cgit v1.2.3