OSDN Git Service

s/burtle/iterative
[pf3gnuchains/gcc-fork.git] / include / hashtab.h
index a3ae5ae..f7bd4ae 100644 (file)
@@ -1,5 +1,5 @@
 /* An expandable hash tables datatype.  
-   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
 
 This program is free software; you can redistribute it and/or modify
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 extern "C" {
 #endif /* __cplusplus */
 
-#include <ansidecl.h>
+#include "ansidecl.h"
 
 #ifndef GTY
 #define GTY(X)
@@ -76,10 +76,16 @@ typedef PTR (*htab_alloc) PARAMS ((size_t, size_t));
 /* We also need a free() routine.  */
 typedef void (*htab_free) PARAMS ((PTR));
 
+/* Memory allocation and deallocation; variants which take an extra
+   argument.  */
+typedef PTR (*htab_alloc_with_arg) PARAMS ((void *, size_t, size_t));
+typedef void (*htab_free_with_arg) PARAMS ((void *, void *));
+
 /* Hash tables are of the following type.  The structure
    (implementation) of this type is not needed for using the hash
    tables.  All work with hash table should be executed only through
-   functions mentioned below. */
+   functions mentioned below.  The size of this structure is subject to
+   change.  */
 
 struct htab GTY(())
 {
@@ -92,10 +98,6 @@ struct htab GTY(())
   /* Pointer to cleanup function.  */
   htab_del del_f;
 
-  /* Pointers to allocate/free functions.  */
-  htab_alloc alloc_f;
-  htab_free free_f;
-  
   /* Table itself.  */
   PTR * GTY ((use_param (""), length ("%h.size"))) entries;
 
@@ -115,6 +117,15 @@ struct htab GTY(())
   /* The following member is used for debugging.  Its value is number
      of collisions fixed for time of work with the hash table. */
   unsigned int collisions;
+
+  /* Pointers to allocate/free functions.  */
+  htab_alloc alloc_f;
+  htab_free free_f;
+
+  /* Alternate allocate/free functions, which take an extra argument.  */
+  PTR GTY((skip (""))) alloc_arg;
+  htab_alloc_with_arg alloc_with_arg_f;
+  htab_free_with_arg free_with_arg_f;
 };
 
 typedef struct htab *htab_t;
@@ -128,9 +139,19 @@ extern htab_t      htab_create_alloc       PARAMS ((size_t, htab_hash,
                                                 htab_eq, htab_del,
                                                 htab_alloc, htab_free));
 
-/* Provided for convenience... */
-#define htab_create(SIZE, HASH, EQ, DEL) \
-  htab_create_alloc (SIZE, HASH, EQ, DEL, xcalloc, free)
+extern htab_t  htab_create_alloc_ex    PARAMS ((size_t, htab_hash,
+                                                   htab_eq, htab_del,
+                                                   PTR, htab_alloc_with_arg,
+                                                   htab_free_with_arg));
+
+/* Backward-compatibility functions.  */
+extern htab_t htab_create PARAMS ((size_t, htab_hash, htab_eq, htab_del));
+extern htab_t htab_try_create PARAMS ((size_t, htab_hash, htab_eq, htab_del));
+
+extern void    htab_set_functions_ex   PARAMS ((htab_t, htab_hash,
+                                                htab_eq, htab_del,
+                                                PTR, htab_alloc_with_arg,
+                                                htab_free_with_arg));
 
 extern void    htab_delete     PARAMS ((htab_t));
 extern void    htab_empty      PARAMS ((htab_t));
@@ -147,6 +168,7 @@ extern void htab_clear_slot PARAMS ((htab_t, void **));
 extern void    htab_remove_elt PARAMS ((htab_t, void *));
 
 extern void    htab_traverse   PARAMS ((htab_t, htab_trav, void *));
+extern void    htab_traverse_noresize  PARAMS ((htab_t, htab_trav, void *));
 
 extern size_t  htab_size       PARAMS ((htab_t));
 extern size_t  htab_elements   PARAMS ((htab_t));
@@ -161,6 +183,11 @@ extern htab_eq htab_eq_pointer;
 /* A hash function for null-terminated strings.  */
 extern hashval_t htab_hash_string PARAMS ((const PTR));
 
+/* An iterative hash function for arbitrary data.  */
+extern hashval_t iterative_hash PARAMS ((const PTR, size_t, hashval_t));
+/* Shorthand for hashing something with an intrinsic size.  */
+#define iterative_hash_object(OB,INIT) iterative_hash (&OB, sizeof (OB), INIT)
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */