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 /st.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 'st.c')
-rw-r--r-- | st.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1816,9 +1816,14 @@ st_hash(const void *ptr, size_t len, st_index_t h) } else #endif +#ifdef HAVE_BUILTIN___BUILTIN_ASSUME_ALIGNED +#define aligned_data __builtin_assume_aligned(data, sizeof(st_index_t)) +#else +#define aligned_data data +#endif { do { - h = murmur_step(h, *(st_index_t *)data); + h = murmur_step(h, *(st_index_t *)aligned_data); data += sizeof(st_index_t); len -= sizeof(st_index_t); } while (len >= sizeof(st_index_t)); @@ -1834,7 +1839,7 @@ st_hash(const void *ptr, size_t len, st_index_t h) case 6: t |= data_at(5) << 40; case 5: t |= data_at(4) << 32; case 4: - t |= (st_index_t)*(uint32_t*)data; + t |= (st_index_t)*(uint32_t*)aligned_data; goto skip_tail; # define SKIP_TAIL 1 #endif @@ -1859,6 +1864,7 @@ st_hash(const void *ptr, size_t len, st_index_t h) h *= C2; } h ^= l; +#undef aligned_data return murmur_finish(h); } |