From a3f9038c879c11344430169d6daa8fad30d4f379 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 28 Aug 2002 07:29:53 +0000 Subject: Roland McGrath * locale/hashval.h (compute_hashval): Use prototype defn. (hashval_t): New macro, defined to unsigned long int if not already defined. (compute_hashval): Return hashval_t instead of unsigned long int. * locale/loadarchive.c (hashval_t): New macro. * locale/programs/locarchive.c: Include hashval.h directly instead of simple-hash.h. (compute_hashval, hashval_t): Define these macros first. (insert_name): Use archive_hashval instead of compute_hashval. (add_locale, delete_locales_from_archive): Likewise. 2002-08-28 Jakub Jelinek --- locale/hashval.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'locale/hashval.h') diff --git a/locale/hashval.h b/locale/hashval.h index f846cdfb27..52ef8b5da9 100644 --- a/locale/hashval.h +++ b/locale/hashval.h @@ -18,20 +18,16 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef LONGBITS -# include -# define LONGBITS (sizeof (long int) * CHAR_BIT) +#ifndef hashval_t +# define hashval_t unsigned long int #endif +#include /* For CHAR_BIT. */ -unsigned long int compute_hashval (const void *key, size_t keylen); - -unsigned long int -compute_hashval (key, keylen) - const void *key; - size_t keylen; +hashval_t +compute_hashval (const void *key, size_t keylen) { size_t cnt; - unsigned long int hval; + hashval_t hval; /* Compute the hash value for the given string. The algorithm is taken from [Aho,Sethi,Ullman], modified to reduce the number of @@ -41,8 +37,8 @@ compute_hashval (key, keylen) hval = keylen; while (cnt < keylen) { - hval = (hval << 9) | (hval >> (LONGBITS - 9)); - hval += (unsigned long int) *(((char *) key) + cnt++); + hval = (hval << 9) | (hval >> (sizeof hval * CHAR_BIT - 9)); + hval += (hashval_t) *(((char *) key) + cnt++); } - return hval != 0 ? hval : ~((unsigned long int) 0); + return hval != 0 ? hval : ~((hashval_t) 0); } -- cgit 1.4.1