From e0f4eafb689e75d66b34c40592024c1e698b0836 Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Mon, 1 Jun 2009 13:40:30 +0000 Subject: Add Bob Jenkins' lookup3 32-bit and 64-bit hashes to pluginlib. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21155 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/lib/jhash.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 apps/plugins/lib/jhash.h (limited to 'apps/plugins/lib/jhash.h') diff --git a/apps/plugins/lib/jhash.h b/apps/plugins/lib/jhash.h new file mode 100644 index 0000000000..97d1ac3d93 --- /dev/null +++ b/apps/plugins/lib/jhash.h @@ -0,0 +1,67 @@ +/*************************************************************************** +* __________ __ ___. +* Open \______ \ ____ ____ | | _\_ |__ _______ ___ +* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +* \/ \/ \/ \/ \/ +* $Id$ +* +* Copyright (C) 2009 by Andrew Mahone +* +* jhash.c headers +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +* KIND, either express or implied. +* +****************************************************************************/ + +#ifndef _LIB_JHASH_H_ +#define _LIB_JHASH_H_ +#include /* defines uint32_t etc */ +#include +#include + +/* +hashw() -- hash an array of uint32_t into a 32-bit value + k: pointer to the key, an array of uint32_t + length: number of elements in the key + initval: an initialization value + returns the 32-bit hash +*/ +uint32_t hashw(const uint32_t *k, size_t length, uint32_t initval); + +/* +hashw() -- hash an array of uint32_t into two 32-bit values +(*pc) will be the same as the return value from hashword(). + k: pointer to the key, an array of uint32_t + length: number of elements in the key + pc, pb: pointers to primary and secondary initial values, also used to store + the hash results. +*/ +void hashw2 (const uint32_t *k, size_t length, uint32_t *pc, uint32_t *pb); + +/* +hashs() -- hash an array of bytes into a 32-bit value + k: pointer to the key, an array of bytes + length: number of elements in the key + initval: an initialization value + returns the 32-bit hash +*/ +uint32_t hashs( const void *key, size_t length, uint32_t initval); + +/* +hashs2() -- hash an array of bytes into two 32-bit values + k: pointer to the key, an array of bytes + length: number of elements in the key + pc, pb: pointers to primary and secondary initial values, also used to store + the hash results. +*/ +void hashs2(const void *key, size_t length, uint32_t *pc, uint32_t *pb); +#endif + -- cgit v1.2.3