diff options
author | Roland McGrath <roland@gnu.org> | 2002-08-28 07:29:53 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2002-08-28 07:29:53 +0000 |
commit | a3f9038c879c11344430169d6daa8fad30d4f379 (patch) | |
tree | 3f8a79ac51aa7200d53aef80763961bff04e21c6 /locale/hashval.h | |
parent | 75261665f1dd29bdfedfe653a8d102fab2d012e6 (diff) | |
download | glibc-a3f9038c879c11344430169d6daa8fad30d4f379.tar glibc-a3f9038c879c11344430169d6daa8fad30d4f379.tar.gz glibc-a3f9038c879c11344430169d6daa8fad30d4f379.tar.bz2 glibc-a3f9038c879c11344430169d6daa8fad30d4f379.zip |
Roland McGrath <roland@redhat.com>
* 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 <jakub@redhat.com>
Diffstat (limited to 'locale/hashval.h')
-rw-r--r-- | locale/hashval.h | 22 |
1 files changed, 9 insertions, 13 deletions
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 <limits.h> -# define LONGBITS (sizeof (long int) * CHAR_BIT) +#ifndef hashval_t +# define hashval_t unsigned long int #endif +#include <limits.h> /* 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); } |