OSDN Git Service

merge from gcc
authordj <dj>
Thu, 6 Jun 2002 12:55:14 +0000 (12:55 +0000)
committerdj <dj>
Thu, 6 Jun 2002 12:55:14 +0000 (12:55 +0000)
include/ChangeLog
include/hashtab.h

index e4b1110..c0a912a 100644 (file)
@@ -1,3 +1,30 @@
+2002-06-06  DJ Delorie  <dj@redhat.com>
+
+       * hashtab.h (htab): Rearrange new members for backward
+       compatibility.
+       (htab_create): Don't use a macro that requires other headers.
+
+2002-06-05  Geoffrey Keating  <geoffk@redhat.com>
+
+       * hashtab.h (htab_create): Restore prototype for backward
+       compatibility.
+       (htab_try_create): Likewise.
+
+2002-05-22  Geoffrey Keating  <geoffk@redhat.com>
+
+       * hashtab.h (struct htab): Update for change to length specifier.
+
+2002-05-10  Geoffrey Keating  <geoffk@redhat.com>
+
+       * hashtab.h (GTY): Define if undefined.
+       (htab_alloc): New typedef.
+       (htab_free): New typedef.
+       (struct htab): Support gengtype; allow user-specified memory
+       allocation.
+       (htab_create_alloc): New.
+       (htab_create): Replace with #define.
+       (htab_try_create): Delete.
+
 2002-05-31  Michal Ludvig  <mludvig@suse.cz>
 
        * elf/dwarf2.h (DW_CFA_low_user, DW_CFA_high_user): Renamed
index 8871710..7fb31e4 100644 (file)
@@ -38,6 +38,10 @@ extern "C" {
 
 #include <ansidecl.h>
 
+#ifndef GTY
+#define GTY(X)
+#endif
+
 /* The type for a hash code.  */
 typedef unsigned int hashval_t;
 
@@ -63,12 +67,21 @@ typedef void (*htab_del) PARAMS ((void *));
    htab_traverse.  Return 1 to continue scan, 0 to stop.  */
 typedef int (*htab_trav) PARAMS ((void **, void *));
 
+/* Memory-allocation function, with the same functionality as calloc().
+   Iff it returns NULL, the hash table implementation will pass an error
+   code back to the user, so if your code doesn't handle errors,
+   best if you use xcalloc instead.  */
+typedef PTR (*htab_alloc) PARAMS ((size_t, size_t));
+
+/* We also need a free() routine.  */
+typedef void (*htab_free) PARAMS ((PTR));
+
 /* 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. */
 
-struct htab
+struct htab GTY(())
 {
   /* Pointer to hash function.  */
   htab_hash hash_f;
@@ -80,7 +93,7 @@ struct htab
   htab_del del_f;
 
   /* Table itself.  */
-  PTR *entries;
+  PTR * GTY ((use_param (""), length ("%h.size"))) entries;
 
   /* Current size (in entries) of the hash table */
   size_t size;
@@ -99,9 +112,9 @@ struct htab
      of collisions fixed for time of work with the hash table. */
   unsigned int collisions;
 
-  /* This is non-zero if we are allowed to return NULL for function calls
-     that allocate memory.  */
-  int return_allocation_failure;
+  /* Pointers to allocate/free functions.  */
+  htab_alloc alloc_f;
+  htab_free free_f;
 };
 
 typedef struct htab *htab_t;
@@ -111,14 +124,14 @@ enum insert_option {NO_INSERT, INSERT};
 
 /* The prototypes of the package functions. */
 
-extern htab_t  htab_create     PARAMS ((size_t, htab_hash,
-                                        htab_eq, htab_del));
+extern htab_t  htab_create_alloc       PARAMS ((size_t, htab_hash,
+                                                htab_eq, htab_del,
+                                                htab_alloc, htab_free));
+
+/* 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));
 
-/* This function is like htab_create, but may return NULL if memory
-   allocation fails, and also signals that htab_find_slot_with_hash and
-   htab_find_slot are allowed to return NULL when inserting.  */
-extern htab_t  htab_try_create PARAMS ((size_t, htab_hash,
-                                        htab_eq, htab_del));
 extern void    htab_delete     PARAMS ((htab_t));
 extern void    htab_empty      PARAMS ((htab_t));