From 8fc34799029ef55fd64a6cd72d592aee9e8ac074 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Fri, 17 Aug 2001 06:33:05 +0000 Subject: [PATCH] merge from gcc --- include/ChangeLog | 4 ++++ include/hashtab.h | 3 +++ libiberty/ChangeLog | 4 ++++ libiberty/hashtab.c | 16 ++++++++++++++++ 4 files changed, 27 insertions(+) diff --git a/include/ChangeLog b/include/ChangeLog index 305754fec0..b7d460e13a 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2001-08-16 Richard Henderson + + * hashtab.h (htab_hash_string): Declare. + 2001-06-13 Andrew Cagney * libiberty.h (lbasename): Change function declaration to return a diff --git a/include/hashtab.h b/include/hashtab.h index a577c5e2af..8871710e5d 100644 --- a/include/hashtab.h +++ b/include/hashtab.h @@ -145,6 +145,9 @@ extern htab_hash htab_hash_pointer; /* An equality function for pointers. */ extern htab_eq htab_eq_pointer; +/* A hash function for null-terminated strings. */ +extern hashval_t htab_hash_string PARAMS ((const PTR)); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index a62db15285..84653bbe2f 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,7 @@ +2001-08-16 Richard Henderson + + * hashtab.c (htab_hash_string): New. + 2001-08-13 Andrew Cagney * floatformat.c (floatformat_ieee_double_littlebyte_bigword): Fix diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index 274ad9ec20..28078027fe 100644 --- a/libiberty/hashtab.c +++ b/libiberty/hashtab.c @@ -561,3 +561,19 @@ htab_collisions (htab) return (double) htab->collisions / (double) htab->searches; } + +/* Hash P as a null-terminated string. */ + +hashval_t +htab_hash_string (p) + const PTR p; +{ + const unsigned char *str = (const unsigned char *) p; + hashval_t r = 0; + unsigned char c; + + while ((c = *str++) != 0) + r = r * 67 + c - 113; + + return r; +} -- 2.34.1