diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-15 02:35:16 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-15 02:35:16 +0000 |
commit | f089a52865bd82a327fe9ef460cecdb812dcb56c (patch) | |
tree | fd2ebe09327942662defac756ae752d0a9134e00 /win32 | |
parent | 630ab3b925cd8b6e3c94250bb7c970d80604dcdc (diff) |
__attibute__((__aligned__)) for RSTRING_PTR()
For instance array.c:rb_ary_product() uses RSTRING_PTR() as an
array of int. So to avoid misaligned memory access RSTRING_PTR()
must at least be sizeof(int)-aligned. However the type of
RSTRING_PTR() is char*, which of course can expect alignment as
much as 1. This is a problem.
The reality is, there is no misaligned memory access because the
memory region behind RSTRING_PTR() is allocated using malloc().
Memory regions returned from malloc() are always aligned
appropriately. So let's tell the compiler about this information.
It seems GCC, clang, and MSVC have such feature.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r-- | win32/Makefile.sub | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 944573f1bb..a3ac277dd2 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -636,6 +636,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub #define PACKED_STRUCT_UNALIGNED(x) x !endif #define RUBY_EXTERN extern __declspec(dllimport) +#define RUBY_ALIGNAS(n) __declspec(align(n)) #define HAVE_DECL_SYS_NERR 1 #define HAVE_LIMITS_H 1 #define HAVE_FCNTL_H 1 |