diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-15 02:35:18 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-15 02:35:18 +0000 |
commit | 39cfa67b4f56e0c79afb352b1e9bf5c914b774ca (patch) | |
tree | 5d8ecc18a42670845571857fc767b8b3e0496566 /string.c | |
parent | 21429b1488faf58b6683eef2c9c24e00796a32ae (diff) |
__builtin_assume_aligned for *(foo *) casts
These casts are guarded. Must be safe to assume alignments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -481,8 +481,15 @@ search_nonascii(const char *p, const char *e) } } #endif - s = (const uintptr_t *)p; - t = (const uintptr_t *)(e - (SIZEOF_VOIDP-1)); +#ifdef HAVE_BUILTIN___BUILTIN_ASSUME_ALIGNED +#define aligned_ptr(value) \ + __builtin_assume_aligned((value), sizeof(uintptr_t *)) +#else +#define aligned_ptr(value) (uintptr_t *)(value) +#endif + s = aligned_ptr(p); + t = aligned_ptr(e - (SIZEOF_VOIDP-1)); +#undef aligned_ptr for (;s < t; s++) { if (*s & NONASCII_MASK) { #ifdef WORDS_BIGENDIAN |