aboutsummaryrefslogtreecommitdiffstats
path: root/st.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-15 02:35:18 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-15 02:35:18 +0000
commit00bbe7a9eca19927efddfe41d437eaf5be36914b (patch)
tree5d8ecc18a42670845571857fc767b8b3e0496566 /st.c
parent8a81fe21faab21ae30bc2e09d44e4796056ad420 (diff)
downloadruby-00bbe7a9eca19927efddfe41d437eaf5be36914b.tar.gz
__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.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/st.c b/st.c
index 5ca6263db0..2e7fc6bfde 100644
--- a/st.c
+++ b/st.c
@@ -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);
}