forked from haskell-unordered-containers/hashable
/
siphash.h
32 lines (23 loc) · 831 Bytes
/
siphash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef _hashable_siphash_h
#define _hashable_siphash_h
#include <stdint.h>
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
#define SIPHASH_ROUNDS 2
#define SIPHASH_FINALROUNDS 4
u64 hashable_siphash(int, int, u64, u64, const u8 *, size_t);
u64 hashable_siphash24(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 */