summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-15 02:35:18 (GMT)
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-15 02:35:18 (GMT)
commit39cfa67b4f56e0c79afb352b1e9bf5c914b774ca (patch)
tree5d8ecc18a42670845571857fc767b8b3e0496566 /st.c
parent21429b1488faf58b6683eef2c9c24e00796a32ae (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.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/st.c b/st.c
index 5ca6263..2e7fc6b 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);
}