]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
hashtab.h (hash_pointer): Declare.
authorMark Mitchell <mark@codesourcery.com>
Mon, 24 Apr 2000 07:29:11 +0000 (07:29 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 24 Apr 2000 07:29:11 +0000 (07:29 +0000)
* 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.

From-SVN: r33372

include/ChangeLog
include/hashtab.h
libiberty/ChangeLog
libiberty/hashtab.c

index 7dd93fb685e56709314e4d95757622c30ceb6a6f..f17e65d42a33ad0e23a6caa3e694d125c5069859 100644 (file)
@@ -1,3 +1,8 @@
+2000-04-24  Mark Mitchell  <mark@codesourcery.com>
+
+       * hashtab.h (hash_pointer): Declare.
+       (eq_pointer): Likewise.
+
 2000-04-23  Mark Mitchell  <mark@codesourcery.com>
 
        * sort.h: New file.
index a516c45f52d474a25e7d478d67fe3124911d6516..12f830ca5ec5286960057f9b889bf1cb25bf5f6c 100644 (file)
@@ -129,6 +129,12 @@ extern size_t      htab_size       PARAMS ((htab_t));
 extern size_t  htab_elements   PARAMS ((htab_t));
 extern double  htab_collisions PARAMS ((htab_t));
 
+/* A hash function for pointers.  */
+extern htab_hash htab_hash_pointer;
+
+/* An equality function for pointers.  */
+extern htab_eq htab_eq_pointer;
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index cfc03e33f9c60ec38a4677bdb5871b64c55eb361..25215d3ba9d2f6ceed170f7b0931e8c08f75eafb 100644 (file)
@@ -1,3 +1,10 @@
+2000-04-24  Mark Mitchell  <mark@codesourcery.com>
+
+       * hashtab.c (hash_pointer): New function.
+       (eq_pointer): Likewise.
+       (htab_hash_pointer): New variable.
+       (htab_eq_pointer): Likewise.
+
 2000-04-23  Mark Mitchell  <mark@codesourcery.com>
 
        * sort.c (sort_pointers): Fix endianness bugs.
index 2d1c09d95228e7208e5b8b10f5c1fa6073980730..9cde177034904366f70aa3756e14b58897ec53fb 100644 (file)
@@ -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