summaryrefslogtreecommitdiff
path: root/libiberty/hashtab.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2000-04-24 07:29:11 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2000-04-24 07:29:11 +0000
commitc9dfb8ae562d44693af93825c4224858bf4c55b3 (patch)
tree488af2866d01b416ccf20f74818935ec34822045 /libiberty/hashtab.c
parent2e841b845ffb8a8cd5fa37d371136b0f4b9b9625 (diff)
downloadgcc-c9dfb8ae562d44693af93825c4224858bf4c55b3.tar.gz
* hashtab.h (hash_pointer): Declare.
(eq_pointer): Likewise. * hashtab.c (hash_pointer): New function. (eq_pointer): Likewise. (htab_hash_pointer): New variable. (htab_eq_pointer): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33372 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/hashtab.c')
-rw-r--r--libiberty/hashtab.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index 2d1c09d9522..9cde1770349 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -56,6 +56,14 @@ Boston, MA 02111-1307, USA. */
#define DELETED_ENTRY ((void *) 1)
static unsigned long higher_prime_number PARAMS ((unsigned long));
+static hashval_t hash_pointer PARAMS ((const void *));
+static int eq_pointer PARAMS ((const void *, const void *));
+
+/* At some point, we could make these be NULL, and modify the
+ hash-table routines to handle NULL specially; that would avoid
+ function-call overhead for the common case of hashing pointers. */
+htab_hash htab_hash_pointer = hash_pointer;
+htab_eq htab_eq_pointer = eq_pointer;
/* The following function returns the nearest prime number which is
greater than a given source number, N. */
@@ -88,6 +96,25 @@ higher_prime_number (n)
return n;
}
+/* Returns a hash code for P. */
+
+hashval_t
+hash_pointer (p)
+ const void *p;
+{
+ return (hashval_t) p;
+}
+
+/* Returns non-zero if P1 and P2 are equal. */
+
+int
+eq_pointer (p1, p2)
+ const void *p1;
+ const void *p2;
+{
+ return p1 == p2;
+}
+
/* This function creates table with length slightly longer than given
source length. Created hash table is initiated as empty (all the
hash table entries are EMPTY_ENTRY). The function returns the