diff options
author | Yves Orton <demerphq@gmail.com> | 2014-06-13 15:51:00 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2014-06-16 09:12:31 +0200 |
commit | 3d53a8ea562200eaacddbecddce21250ffed9eee (patch) | |
tree | 505882610575642b75ce13dcd8a1b6c77ff4b79c /hv_func.h | |
parent | dc8b0d96b6966e02546ba8edb5b9bb9effd5b25e (diff) | |
download | perl-3d53a8ea562200eaacddbecddce21250ffed9eee.tar.gz |
Make hash_value() accept an optional seed
Diffstat (limited to 'hv_func.h')
-rw-r--r-- | hv_func.h | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -28,38 +28,38 @@ #if defined(PERL_HASH_FUNC_SIPHASH) # define PERL_HASH_FUNC "SIPHASH_2_4" # define PERL_HASH_SEED_BYTES 16 -# define PERL_HASH(hash,str,len) (hash)= S_perl_hash_siphash_2_4(PERL_HASH_SEED,(U8*)(str),(len)) +# define PERL_HASH_WITH_SEED(seed,hash,str,len) (hash)= S_perl_hash_siphash_2_4((seed),(U8*)(str),(len)) #elif defined(PERL_HASH_FUNC_SUPERFAST) # define PERL_HASH_FUNC "SUPERFAST" # define PERL_HASH_SEED_BYTES 4 -# define PERL_HASH(hash,str,len) (hash)= S_perl_hash_superfast(PERL_HASH_SEED,(U8*)(str),(len)) +# define PERL_HASH_WITH_SEED(seed,hash,str,len) (hash)= S_perl_hash_superfast((seed),(U8*)(str),(len)) #elif defined(PERL_HASH_FUNC_MURMUR3) # define PERL_HASH_FUNC "MURMUR3" # define PERL_HASH_SEED_BYTES 4 -# define PERL_HASH(hash,str,len) (hash)= S_perl_hash_murmur3(PERL_HASH_SEED,(U8*)(str),(len)) +# define PERL_HASH_WITH_SEED(seed,hash,str,len) (hash)= S_perl_hash_murmur3((seed),(U8*)(str),(len)) #elif defined(PERL_HASH_FUNC_DJB2) # define PERL_HASH_FUNC "DJB2" # define PERL_HASH_SEED_BYTES 4 -# define PERL_HASH(hash,str,len) (hash)= S_perl_hash_djb2(PERL_HASH_SEED,(U8*)(str),(len)) +# define PERL_HASH_WITH_SEED(seed,hash,str,len) (hash)= S_perl_hash_djb2((seed),(U8*)(str),(len)) #elif defined(PERL_HASH_FUNC_SDBM) # define PERL_HASH_FUNC "SDBM" # define PERL_HASH_SEED_BYTES 4 -# define PERL_HASH(hash,str,len) (hash)= S_perl_hash_sdbm(PERL_HASH_SEED,(U8*)(str),(len)) +# define PERL_HASH_WITH_SEED(seed,hash,str,len) (hash)= S_perl_hash_sdbm((seed),(U8*)(str),(len)) #elif defined(PERL_HASH_FUNC_ONE_AT_A_TIME_HARD) # define PERL_HASH_FUNC "ONE_AT_A_TIME_HARD" # define PERL_HASH_SEED_BYTES 8 -# define PERL_HASH(hash,str,len) (hash)= S_perl_hash_one_at_a_time_hard(PERL_HASH_SEED,(U8*)(str),(len)) +# define PERL_HASH_WITH_SEED(seed,hash,str,len) (hash)= S_perl_hash_one_at_a_time_hard((seed),(U8*)(str),(len)) #elif defined(PERL_HASH_FUNC_ONE_AT_A_TIME) # define PERL_HASH_FUNC "ONE_AT_A_TIME" # define PERL_HASH_SEED_BYTES 4 -# define PERL_HASH(hash,str,len) (hash)= S_perl_hash_one_at_a_time(PERL_HASH_SEED,(U8*)(str),(len)) +# define PERL_HASH_WITH_SEED(seed,hash,str,len) (hash)= S_perl_hash_one_at_a_time((seed),(U8*)(str),(len)) #elif defined(PERL_HASH_FUNC_ONE_AT_A_TIME_OLD) # define PERL_HASH_FUNC "ONE_AT_A_TIME_OLD" # define PERL_HASH_SEED_BYTES 4 -# define PERL_HASH(hash,str,len) (hash)= S_perl_hash_old_one_at_a_time(PERL_HASH_SEED,(U8*)(str),(len)) +# define PERL_HASH_WITH_SEED(seed,hash,str,len) (hash)= S_perl_hash_old_one_at_a_time((seed),(U8*)(str),(len)) #endif -#ifndef PERL_HASH +#ifndef PERL_HASH_WITH_SEED #error "No hash function defined!" #endif #ifndef PERL_HASH_SEED_BYTES @@ -81,6 +81,8 @@ # endif #endif +#define PERL_HASH(hash,str,len) PERL_HASH_WITH_SEED(PERL_HASH_SEED,hash,str,len) + /*----------------------------------------------------------------------------- * Endianess, misalignment capabilities and util macros * |