<minix/hash.h>
This commit is contained in:
parent
ddde360e3e
commit
b0d7ce8d09
2 changed files with 50 additions and 1 deletions
|
@ -29,7 +29,7 @@ INCS+= minix/a.out.h minix/bitmap.h minix/callnr.h minix/cdrom.h \
|
||||||
minix/sysutil.h minix/timers.h minix/tty.h minix/type.h minix/types.h \
|
minix/sysutil.h minix/timers.h minix/tty.h minix/type.h minix/types.h \
|
||||||
minix/u64.h minix/vfsif.h minix/vm.h minix/vtreefs.h minix/gcov.h \
|
minix/u64.h minix/vfsif.h minix/vm.h minix/vtreefs.h minix/gcov.h \
|
||||||
minix/compiler.h minix/compiler-ack.h minix/sha2.h minix/sha1.h minix/md5.h \
|
minix/compiler.h minix/compiler-ack.h minix/sha2.h minix/sha1.h minix/md5.h \
|
||||||
minix/audio_fw.h
|
minix/audio_fw.h minix/hash.h
|
||||||
INCS+= net/hton.h net/if.h net/ioctl.h net/netlib.h
|
INCS+= net/hton.h net/if.h net/ioctl.h net/netlib.h
|
||||||
INCS+= net/gen/arp_io.h net/gen/dhcp.h net/gen/ether.h \
|
INCS+= net/gen/arp_io.h net/gen/dhcp.h net/gen/ether.h \
|
||||||
net/gen/eth_hdr.h net/gen/eth_io.h net/gen/icmp.h \
|
net/gen/eth_hdr.h net/gen/eth_io.h net/gen/icmp.h \
|
||||||
|
|
49
include/minix/hash.h
Normal file
49
include/minix/hash.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
|
||||||
|
#ifndef _MINIX_HASH_H
|
||||||
|
#define _MINIX_HASH_H 1
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/* This code is taken from:
|
||||||
|
* lookup3.c, by Bob Jenkins, May 2006, Public Domain.
|
||||||
|
* (macro names modified)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define hash_rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
|
||||||
|
|
||||||
|
#define hash_mix(a,b,c) \
|
||||||
|
{ \
|
||||||
|
a -= c; a ^= hash_rot(c, 4); c += b; \
|
||||||
|
b -= a; b ^= hash_rot(a, 6); a += c; \
|
||||||
|
c -= b; c ^= hash_rot(b, 8); b += a; \
|
||||||
|
a -= c; a ^= hash_rot(c,16); c += b; \
|
||||||
|
b -= a; b ^= hash_rot(a,19); a += c; \
|
||||||
|
c -= b; c ^= hash_rot(b, 4); b += a; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define hash_final(a,b,c) \
|
||||||
|
{ \
|
||||||
|
c ^= b; c -= hash_rot(b,14); \
|
||||||
|
a ^= c; a -= hash_rot(c,11); \
|
||||||
|
b ^= a; b -= hash_rot(a,25); \
|
||||||
|
c ^= b; c -= hash_rot(b,16); \
|
||||||
|
a ^= c; a -= hash_rot(c,4); \
|
||||||
|
b ^= a; b -= hash_rot(a,14); \
|
||||||
|
c ^= b; c -= hash_rot(b,24); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define hash_i_64(a, u, v) { \
|
||||||
|
u32_t i1 = (a), i2 = ex64lo(u), i3 = ex64hi(u); \
|
||||||
|
hash_mix(i1, i2, i3); \
|
||||||
|
hash_final(i1, i2, i3); \
|
||||||
|
(v) = i3; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define hash_32(n, v) { \
|
||||||
|
u32_t i1 = 0xa5a5a5a5, i2 = 0x12345678, i3 = n; \
|
||||||
|
hash_mix(i1, i2, i3); \
|
||||||
|
hash_final(i1, i2, i3); \
|
||||||
|
(v) = i3; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue