merge from gcc

This commit is contained in:
DJ Delorie
2010-06-10 18:30:24 +00:00
parent f3a2388fc9
commit 219a461e6c
7 changed files with 183 additions and 39 deletions

View 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>

View 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})

View 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).
@@ -291,39 +291,17 @@ 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)
{
htab_t result;
unsigned int size_prime_index;
size_prime_index = higher_prime_index (size);
size = prime_tab[size_prime_index].prime;
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->size_prime_index = size_prime_index;
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;
return result;
return htab_create_typed_alloc (size, hash_f, eq_f, del_f, alloc_f, alloc_f,
free_f);
}
/* As above, but use the variants of alloc_f and free_f which accept
/* 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_del del_f, void *alloc_arg,
htab_alloc_with_arg alloc_f,
htab_free_with_arg free_f)
{
htab_t result;
@@ -353,6 +331,59 @@ htab_create_alloc_ex (size_t size, htab_hash hash_f, htab_eq eq_f,
return result;
}
/*
@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_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;
size_prime_index = higher_prime_index (size);
size = prime_tab[size_prime_index].prime;
result = (htab_t) (*alloc_tab_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->size_prime_index = size_prime_index;
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;
return result;
}
/* Update the function pointers and allocation parameter in the htab_t. */
void

View 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;