merge from gcc
authorDJ Delorie <dj@redhat.com>
Thu, 10 Jun 2010 18:30:24 +0000 (18:30 +0000)
committerDJ Delorie <dj@redhat.com>
Thu, 10 Jun 2010 18:30:24 +0000 (18:30 +0000)
include/ChangeLog
include/hashtab.h
include/splay-tree.h
libiberty/ChangeLog
libiberty/functions.texi
libiberty/hashtab.c
libiberty/splay-tree.c

index bfe4f3c6f564e441e2af4fae5df58a4c7d1e9dc6..97e8da5dc5e487a248bbe499fe7b3d461c6f2758 100644 (file)
@@ -1,3 +1,12 @@
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * splay-tree.h: Update copyright years.
+       (splay_tree_s): Document fields.
+       (splay_tree_new_typed_alloc): New.
+
+       * hashtab.h: Update copyright years.
+       (htab_create_typed_alloc): New.
+
 2010-06-10  Tristan Gingold  <gingold@adacore.com>
 
        * dwarf2.h (enum dwarf_tag): Add DW_TAG_HP_Bliss_field and
index 1cd406daf31148c720e9ed118559508e6a165d47..4bb65d6c7a2b4135b8526ca5ec4255987934ed6d 100644 (file)
@@ -1,5 +1,5 @@
 /* An expandable hash tables datatype.  
-   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2009
+   Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
 
@@ -157,6 +157,9 @@ extern htab_t       htab_create_alloc_ex (size_t, htab_hash,
                                       void *, htab_alloc_with_arg,
                                       htab_free_with_arg);
 
+extern htab_t  htab_create_typed_alloc (size_t, htab_hash, htab_eq, htab_del,
+                                       htab_alloc, htab_alloc, htab_free);
+
 /* Backward-compatibility functions.  */
 extern htab_t htab_create (size_t, htab_hash, htab_eq, htab_del);
 extern htab_t htab_try_create (size_t, htab_hash, htab_eq, htab_del);
index 57a96c4a3de58a5504a931d4e19bc4eb0386a9da..480b2c43e7d4d654e971ce77a6ac67dc860ebfcc 100644 (file)
@@ -1,5 +1,5 @@
 /* A splay-tree datatype.  
-   Copyright 1998, 1999, 2000, 2002, 2005, 2007, 2009
+   Copyright 1998, 1999, 2000, 2002, 2005, 2007, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Mark Mitchell (mark@markmitchell.com).
 
@@ -119,9 +119,13 @@ struct GTY(()) splay_tree_s {
   /* The deallocate-value function.  NULL if no cleanup is necessary.  */
   splay_tree_delete_value_fn delete_value;
 
-  /* Allocate/free functions, and a data pointer to pass to them.  */
+  /* Node allocate function.  Takes allocate_data as a parameter. */
   splay_tree_allocate_fn allocate;
+
+  /* Free function for nodes and trees.  Takes allocate_data as a parameter.  */
   splay_tree_deallocate_fn deallocate;
+
+  /* Parameter for allocate/free functions.  */
   void * GTY((skip)) allocate_data;
 };
 
@@ -136,6 +140,13 @@ extern splay_tree splay_tree_new_with_allocator (splay_tree_compare_fn,
                                                 splay_tree_allocate_fn,
                                                 splay_tree_deallocate_fn,
                                                 void *);
+extern splay_tree splay_tree_new_typed_alloc (splay_tree_compare_fn,
+                                             splay_tree_delete_key_fn,
+                                             splay_tree_delete_value_fn,
+                                             splay_tree_allocate_fn,
+                                             splay_tree_allocate_fn,
+                                             splay_tree_deallocate_fn,
+                                             void *);
 extern void splay_tree_delete (splay_tree);
 extern splay_tree_node splay_tree_insert (splay_tree,
                                          splay_tree_key,
index 4c0cba85cef3b3fbbbd730f499e499f9c3dc937e..ea95ca54a7014675d5d1c2b7b15de5d344b4018d 100644 (file)
@@ -9,6 +9,18 @@
        call.
        * testsuite/demangle-expected: Add a test for this.
 
+2010-06-08  Laurynas Biveinis  <laurynas.biveinis@gmail.com>
+
+       * splay-tree.c: Update copyright years.
+       (splay_tree_new_typed_alloc): New.
+       (splay_tree_new_with_allocator): Use it.
+
+       * hashtab.c: Update copyright years.
+       (htab_create_typed_alloc): New.
+       (htab_create_alloc): Use it.
+
+       * functions.texi: Regenerate.
+
 2010-06-03  Joern Rennecke <joern.rennecke@embecosm.com>
            Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
index 72ca56cbd44dcd192ff59afdb14116fcf99a668f..d9fef8cb7b348efe2c8d065747a823beb3ad6475 100644 (file)
@@ -3,7 +3,7 @@
 @c Edit the *.c files, configure with --enable-maintainer-mode,
 @c run 'make stamp-functions' and gather-docs will build a new copy.
 
-@c safe-ctype.c:25
+@c splay-tree.c:277
 @defvr Extension HOST_CHARSET
 This macro indicates the basic character set and encoding used by the
 host: more precisely, the encoding used for character constants in
@@ -24,6 +24,25 @@ The host character set is some variant of EBCDIC.  (Only one of the
 nineteen EBCDIC varying characters is tested; exercise caution.)
 @end ftable
 @end defvr
+@deftypefn Supplemental splay_tree splay_tree_new_with_typed_alloc
+(splay_tree_compare_fn @var{compare_fn},
+splay_tree_delete_key_fn @var{delete_key_fn},
+splay_tree_delete_value_fn @var{delete_value_fn},
+splay_tree_allocate_fn @var{tree_allocate_fn},
+splay_tree_allocate_fn @var{node_allocate_fn},
+splay_tree_deallocate_fn @var{deallocate_fn},
+void * @var{allocate_data})
+
+This function creates a splay tree that uses two different allocators
+@var{tree_allocate_fn} and @var{node_allocate_fn} to use for allocating the
+tree itself and its nodes respectively.  This is useful when variables of
+different types need to be allocated with different allocators.
+
+The splay tree will use @var{compare_fn} to compare nodes,
+@var{delete_key_fn} to deallocate keys, and @var{delete_value_fn} to
+deallocate values.
+
+@end deftypefn
 
 @c alloca.c:26
 @deftypefn Replacement void* alloca (size_t @var{size})
@@ -477,6 +496,24 @@ systems.
 
 @end deftypefn
 
+@c hashtab.c:336
+@deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size},
+htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f},
+htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f},
+htab_free @var{free_f})
+
+This function creates a hash table that uses two different allocators
+@var{alloc_tab_f} and @var{alloc_f} to use for allocating the table itself
+and its entries respectively.  This is useful when variables of different
+types need to be allocated with different allocators.
+
+The created hash table is slightly larger than @var{size} and it is
+initially empty (all the hash table entries are @code{HTAB_EMPTY_ENTRY}).
+The function returns the created hash table, or @code{NULL} if memory
+allocation fails.
+
+@end deftypefn
+
 @c index.c:5
 @deftypefn Supplemental char* index (char *@var{s}, int @var{c})
 
index 8c89bfcd8393e8fde1e6b38847bd85f618c5ae25..359e3ea569ec084fb58fda182cb0a3526ad20420 100644 (file)
@@ -1,5 +1,5 @@
 /* An expandable hash tables datatype.  
-   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2009
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
 
@@ -290,6 +290,19 @@ htab_mod_m2 (hashval_t hash, htab_t htab)
 htab_t
 htab_create_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
                    htab_del del_f, htab_alloc alloc_f, htab_free free_f)
+{
+  return htab_create_typed_alloc (size, hash_f, eq_f, del_f, alloc_f, alloc_f,
+                                 free_f);
+}
+
+/* As above, but uses the variants of ALLOC_F and FREE_F which accept
+   an extra argument.  */
+
+htab_t
+htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
+                     htab_del del_f, void *alloc_arg,
+                     htab_alloc_with_arg alloc_f,
+                     htab_free_with_arg free_f)
 {
   htab_t result;
   unsigned int size_prime_index;
@@ -297,14 +310,14 @@ htab_create_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
   size_prime_index = higher_prime_index (size);
   size = prime_tab[size_prime_index].prime;
 
-  result = (htab_t) (*alloc_f) (1, sizeof (struct htab));
+  result = (htab_t) (*alloc_f) (alloc_arg, 1, sizeof (struct htab));
   if (result == NULL)
     return NULL;
-  result->entries = (PTR *) (*alloc_f) (size, sizeof (PTR));
+  result->entries = (PTR *) (*alloc_f) (alloc_arg, size, sizeof (PTR));
   if (result->entries == NULL)
     {
       if (free_f != NULL)
-       (*free_f) (result);
+       (*free_f) (alloc_arg, result);
       return NULL;
     }
   result->size = size;
@@ -312,19 +325,37 @@ htab_create_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
   result->hash_f = hash_f;
   result->eq_f = eq_f;
   result->del_f = del_f;
-  result->alloc_f = alloc_f;
-  result->free_f = free_f;
+  result->alloc_arg = alloc_arg;
+  result->alloc_with_arg_f = alloc_f;
+  result->free_with_arg_f = free_f;
   return result;
 }
 
-/* As above, but use the variants of alloc_f and free_f which accept
-   an extra argument.  */
+/*
+
+@deftypefn Supplemental htab_t htab_create_typed_alloc (size_t @var{size},
+htab_hash @var{hash_f}, htab_eq @var{eq_f}, htab_del @var{del_f},
+htab_alloc @var{alloc_tab_f}, htab_alloc @var{alloc_f},
+htab_free @var{free_f})
+
+This function creates a hash table that uses two different allocators
+@var{alloc_tab_f} and @var{alloc_f} to use for allocating the table itself
+and its entries respectively.  This is useful when variables of different
+types need to be allocated with different allocators.
+
+The created hash table is slightly larger than @var{size} and it is
+initially empty (all the hash table entries are @code{HTAB_EMPTY_ENTRY}).
+The function returns the created hash table, or @code{NULL} if memory
+allocation fails.
+
+@end deftypefn
+
+*/
 
 htab_t
-htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
-                      htab_del del_f, void *alloc_arg,
-                      htab_alloc_with_arg alloc_f,
-                     htab_free_with_arg free_f)
+htab_create_typed_alloc (size_t size, htab_hash hash_f, htab_eq eq_f,
+                        htab_del del_f, htab_alloc alloc_tab_f,
+                        htab_alloc alloc_f, htab_free free_f)
 {
   htab_t result;
   unsigned int size_prime_index;
@@ -332,14 +363,14 @@ htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
   size_prime_index = higher_prime_index (size);
   size = prime_tab[size_prime_index].prime;
 
-  result = (htab_t) (*alloc_f) (alloc_arg, 1, sizeof (struct htab));
+  result = (htab_t) (*alloc_tab_f) (1, sizeof (struct htab));
   if (result == NULL)
     return NULL;
-  result->entries = (PTR *) (*alloc_f) (alloc_arg, size, sizeof (PTR));
+  result->entries = (PTR *) (*alloc_f) (size, sizeof (PTR));
   if (result->entries == NULL)
     {
       if (free_f != NULL)
-       (*free_f) (alloc_arg, result);
+       (*free_f) (result);
       return NULL;
     }
   result->size = size;
@@ -347,12 +378,12 @@ htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
   result->hash_f = hash_f;
   result->eq_f = eq_f;
   result->del_f = del_f;
-  result->alloc_arg = alloc_arg;
-  result->alloc_with_arg_f = alloc_f;
-  result->free_with_arg_f = free_f;
+  result->alloc_f = alloc_f;
+  result->free_f = free_f;
   return result;
 }
 
+
 /* Update the function pointers and allocation parameter in the htab_t.  */
 
 void
index d7ed86813dc553007827b3208590e8e9ffff9b0a..bf1a0f3f151f36d641510c86de9c592b9b055686 100644 (file)
@@ -1,5 +1,6 @@
 /* A splay-tree datatype.  
-   Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2001, 2009,
+   2010 Free Software Foundation, Inc.
    Contributed by Mark Mitchell (mark@markmitchell.com).
 
 This file is part of GNU CC.
@@ -265,13 +266,53 @@ splay_tree_new_with_allocator (splay_tree_compare_fn compare_fn,
                                splay_tree_deallocate_fn deallocate_fn,
                                void *allocate_data)
 {
-  splay_tree sp = (splay_tree) (*allocate_fn) (sizeof (struct splay_tree_s),
-                                               allocate_data);
+  return
+    splay_tree_new_typed_alloc (compare_fn, delete_key_fn, delete_value_fn,
+                               allocate_fn, allocate_fn, deallocate_fn,
+                               allocate_data);
+}
+
+/*
+
+@deftypefn Supplemental splay_tree splay_tree_new_with_typed_alloc
+(splay_tree_compare_fn @var{compare_fn},
+splay_tree_delete_key_fn @var{delete_key_fn},
+splay_tree_delete_value_fn @var{delete_value_fn},
+splay_tree_allocate_fn @var{tree_allocate_fn},
+splay_tree_allocate_fn @var{node_allocate_fn},
+splay_tree_deallocate_fn @var{deallocate_fn},
+void * @var{allocate_data})
+
+This function creates a splay tree that uses two different allocators
+@var{tree_allocate_fn} and @var{node_allocate_fn} to use for allocating the
+tree itself and its nodes respectively.  This is useful when variables of
+different types need to be allocated with different allocators.
+
+The splay tree will use @var{compare_fn} to compare nodes,
+@var{delete_key_fn} to deallocate keys, and @var{delete_value_fn} to
+deallocate values.
+
+@end deftypefn
+
+*/
+
+splay_tree
+splay_tree_new_typed_alloc (splay_tree_compare_fn compare_fn,
+                           splay_tree_delete_key_fn delete_key_fn,
+                           splay_tree_delete_value_fn delete_value_fn,
+                           splay_tree_allocate_fn tree_allocate_fn,
+                           splay_tree_allocate_fn node_allocate_fn,
+                           splay_tree_deallocate_fn deallocate_fn,
+                           void * allocate_data)
+{
+  splay_tree sp = (splay_tree) (*tree_allocate_fn)
+    (sizeof (struct splay_tree_s), allocate_data);
+
   sp->root = 0;
   sp->comp = compare_fn;
   sp->delete_key = delete_key_fn;
   sp->delete_value = delete_value_fn;
-  sp->allocate = allocate_fn;
+  sp->allocate = node_allocate_fn;
   sp->deallocate = deallocate_fn;
   sp->allocate_data = allocate_data;
 
@@ -313,10 +354,10 @@ splay_tree_insert (splay_tree sp, splay_tree_key key, splay_tree_value value)
     {
       /* Create a new node, and insert it at the root.  */
       splay_tree_node node;
-      
+
       node = ((splay_tree_node)
-              (*sp->allocate) (sizeof (struct splay_tree_node_s),
-                               sp->allocate_data));
+             (*sp->allocate) (sizeof (struct splay_tree_node_s),
+                              sp->allocate_data));
       node->key = key;
       node->value = value;
       
This page took 0.038025 seconds and 4 git commands to generate.