Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use 16-byte stack alignment on Windows, if using SSE

  • Loading branch information...
commit 9f8a92329efad8a14294e0006f7a279087e994bd 1 parent 2e3ebc1
@bos authored
Showing with 13 additions and 3 deletions.
  1. +13 −3 cbits/siphash.h
View
16 cbits/siphash.h
@@ -14,9 +14,19 @@ typedef uint8_t u8;
u64 hashable_siphash(int, int, u64, u64, const u8 *, size_t);
u64 hashable_siphash24(u64, u64, const u8 *, size_t);
-#if defined(__i386)
-u64 hashable_siphash24_sse2(u64, u64, const u8 *, size_t);
-u64 hashable_siphash24_sse41(u64, u64, const u8 *, size_t);
+#if defined(__i386) || defined(__x86_64)
+
+/* To use SSE instructions on Windows, we have to adjust the stack
+ from its default of 4-byte alignment to use 16-byte alignment. */
+
+# if defined(_WIN32)
+# define ALIGNED_STACK __attribute__((force_align_arg_pointer))
+# else
+# define ALIGNED_STACK
+# endif
+
+u64 hashable_siphash24_sse2(u64, u64, const u8 *, size_t) ALIGNED_STACK;
+u64 hashable_siphash24_sse41(u64, u64, const u8 *, size_t) ALIGNED_STACK;
#endif
#endif /* _hashable_siphash_h */
Please sign in to comment.
Something went wrong with that request. Please try again.