merge from gcc
authorDJ Delorie <dj@redhat.com>
Thu, 6 Jun 2002 12:55:24 +0000 (12:55 +0000)
committerDJ Delorie <dj@redhat.com>
Thu, 6 Jun 2002 12:55:24 +0000 (12:55 +0000)
include/ChangeLog
include/hashtab.h
libiberty/ChangeLog
libiberty/configure
libiberty/configure.in
libiberty/hashtab.c

index e4b1110228d75289e0d1b9382402a1c12f2fd7f0..c0a912af55400f9546460eee8de3f7a5de7333a7 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 8871710e5d8b1694a760f17730d85045f7cbc0ea..7fb31e48c4e2a9157633fb43b09962adb3304533 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));
 
index 89fca1eaf92ff2d68de4ad2d6541c3b746d54db3..916995e5b12429398437af77c57bc6d11625b2da 100644 (file)
@@ -1,3 +1,22 @@
+2002-06-05  Geoffrey Keating  <geoffk@redhat.com>
+
+       * hashtab.c (htab_create): New stub function for backward
+       compatibility.
+       (htab_try_create): Likewise.
+
+2002-06-03  Geoffrey Keating  <geoffk@redhat.com>
+
+       * hashtab.c (htab_create): Delete.
+       (htab_try_create): Delete.
+       (htab_create_alloc): New.
+       (htab_delete): Support user-specified memory allocation.
+       (htab_expand): Likewise.
+
+2002-05-22  Roman Lechtchinsky  <rl@cs.tu-berlin.de>
+
+       * configure.in: Fix typo in the code checking for sys_errlist.
+       * configure: Regenerated.
+
 2002-05-13  Andreas Schwab  <schwab@suse.de>
 
        * config.table: Use mh-x86pic also for x86-64.
@@ -30,7 +49,7 @@
 
 2002-03-30  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>
 
-       * cp-demangle.c (java_demangle_v3): Don't try to release "demangled"
+       * cp-demangle.c (java_demangle_v3): Don't try to release "demangled" 
        if it is NULL.
 
 2002-03-27  DJ Delorie  <dj@redhat.com>
 
        * xmalloc.c (xmalloc_fail): Clarify error message.
 
-2002-02-21  Jim Blandy  <jimb@redhat.com>
+2002-02-22  Jim Blandy  <jimb@redhat.com>
 
        * splay-tree.c (splay_tree_xmalloc_allocate,
        splay_tree_xmalloc_deallocate): New functions.
index fc89885f30510f0de35bafc6de17decfe97e458e..7f2c0a931a3d6c9c18ee9eea7b1d1b56444b33ad 100755 (executable)
@@ -2860,7 +2860,7 @@ else
 #include "confdefs.h"
 int *p;
 int main() {
-extern int $v []; p = &$v;
+extern int $v []; p = $v;
 ; return 0; }
 EOF
 if { (eval echo configure:2867: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
index f6d92bcb03e1ba9b5e9287d1cb791d52eaa7f651..c84ece4ef41ba45435999145c2fd7040e2ae9dcc 100644 (file)
@@ -401,7 +401,7 @@ if test -z "${setobjs}"; then
   for v in $vars; do
     AC_MSG_CHECKING([for $v])
     AC_CACHE_VAL(libiberty_cv_var_$v,
-      [AC_TRY_LINK([int *p;], [extern int $v []; p = &$v;],
+      [AC_TRY_LINK([int *p;], [extern int $v []; p = $v;],
                   [eval "libiberty_cv_var_$v=yes"],
                   [eval "libiberty_cv_var_$v=no"])])
     if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
index 7477c35c3bc0b93eb65f2dca76bbd73a681d2e3d..6bf59ff7378ef18d9d0951e038d15f4efa30e111 100644 (file)
@@ -158,60 +158,60 @@ eq_pointer (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
-   created hash table.  Memory allocation must not fail.  */
+   created hash table, or NULL if memory allocation fails.  */
 
 htab_t
-htab_create (size, hash_f, eq_f, del_f)
+htab_create_alloc (size, hash_f, eq_f, del_f, alloc_f, free_f)
      size_t size;
      htab_hash hash_f;
      htab_eq eq_f;
      htab_del del_f;
+     htab_alloc alloc_f;
+     htab_free free_f;
 {
   htab_t result;
 
   size = higher_prime_number (size);
-  result = (htab_t) xcalloc (1, sizeof (struct htab));
-  result->entries = (PTR *) xcalloc (size, sizeof (PTR));
+  result = (htab_t) (*alloc_f) (1, sizeof (struct htab));
+  if (result == NULL)
+    return NULL;
+  result->entries = (PTR *) (*alloc_f) (size, sizeof (PTR));
+  if (result->entries == NULL)
+    {
+      if (free_f != NULL)
+       (*free_f) (result);
+      return NULL;
+    }
   result->size = size;
   result->hash_f = hash_f;
   result->eq_f = eq_f;
   result->del_f = del_f;
-  result->return_allocation_failure = 0;
+  result->alloc_f = alloc_f;
+  result->free_f = free_f;
   return result;
 }
 
-/* This function creates table with length slightly longer than given
-   source length.  The created hash table is initiated as empty (all the
-   hash table entries are EMPTY_ENTRY).  The function returns the created
-   hash table.  Memory allocation may fail; it may return NULL.  */
+/* These functions exist solely for backward compatibility.  */
 
+#undef htab_create
 htab_t
-htab_try_create (size, hash_f, eq_f, del_f)
+htab_create (size, hash_f, eq_f, del_f)
      size_t size;
      htab_hash hash_f;
      htab_eq eq_f;
      htab_del del_f;
 {
-  htab_t result;
-
-  size = higher_prime_number (size);
-  result = (htab_t) calloc (1, sizeof (struct htab));
-  if (result == NULL)
-    return NULL;
-
-  result->entries = (PTR *) calloc (size, sizeof (PTR));
-  if (result->entries == NULL)
-    {
-      free (result);
-      return NULL;
-    }
+  return htab_create_alloc (size, hash_f, eq_f, del_f, xcalloc, free);
+}
 
-  result->size = size;
-  result->hash_f = hash_f;
-  result->eq_f = eq_f;
-  result->del_f = del_f;
-  result->return_allocation_failure = 1;
-  return result;
+htab_t
+htab_try_create (size, hash_f, eq_f, del_f)
+     size_t size;
+     htab_hash hash_f;
+     htab_eq eq_f;
+     htab_del del_f;
+{
+  return htab_create_alloc (size, hash_f, eq_f, del_f, calloc, free);
 }
 
 /* This function frees all memory allocated for given hash table.
@@ -229,8 +229,11 @@ htab_delete (htab)
          && htab->entries[i] != DELETED_ENTRY)
        (*htab->del_f) (htab->entries[i]);
 
-  free (htab->entries);
-  free (htab);
+  if (htab->free_f != NULL)
+    {
+      (*htab->free_f) (htab->entries);
+      (*htab->free_f) (htab);
+    }
 }
 
 /* This function clears all entries in the given hash table.  */
@@ -302,21 +305,17 @@ htab_expand (htab)
   PTR *oentries;
   PTR *olimit;
   PTR *p;
+  PTR *nentries;
 
   oentries = htab->entries;
   olimit = oentries + htab->size;
 
   htab->size = higher_prime_number (htab->size * 2);
 
-  if (htab->return_allocation_failure)
-    {
-      PTR *nentries = (PTR *) calloc (htab->size, sizeof (PTR *));
-      if (nentries == NULL)
-       return 0;
-      htab->entries = nentries;
-    }
-  else
-    htab->entries = (PTR *) xcalloc (htab->size, sizeof (PTR *));
+  nentries = (PTR *) (*htab->alloc_f) (htab->size, sizeof (PTR *));
+  if (nentries == NULL)
+    return 0;
+  htab->entries = nentries;
 
   htab->n_elements -= htab->n_deleted;
   htab->n_deleted = 0;
@@ -337,7 +336,8 @@ htab_expand (htab)
     }
   while (p < olimit);
 
-  free (oentries);
+  if (htab->free_f != NULL)
+    (*htab->free_f) (oentries);
   return 1;
 }
 
This page took 0.032861 seconds and 4 git commands to generate.