Commit Graph

41 Commits

Author SHA1 Message Date
Richard Henderson 9bf3c9cc6d hashtab.c: Include limits.h, stdint.h, ansidecl.h.
* hashtab.c: Include limits.h, stdint.h, ansidecl.h.
        (CHAR_BIT): Provide default.
        (struct prime_ent, prime_tab): New.
        (higher_prime_index): Rename from higher_prime_number, return index.
        (htab_mod_1): New.
        (htab_mod, htab_mod_m2): Use it.
        (htab_create_alloc, htab_create_alloc_ex): Store prime index.
        (htab_expand): Likewise.
        * configure.ac: Check for stdint.h.
        (UNSIGNED_64BIT_TYPE): New define and checks to fill it in.
        * config.in, configure: Rebuild.

From-SVN: r81029
2004-04-22 10:35:44 -07:00
Jeff Law 7f96816adb hashtab.c (htab_remove_elt_with_hash): New function.
* hashtab.c (htab_remove_elt_with_hash): New function.
	(htab_remove_elt): Implement in terms of htab_remove_elt_with_hash.

	* hashtab.h (htab_remove_elt_with_hash): Prototype new function.

From-SVN: r80641
2004-04-13 08:48:56 -06:00
Richard Henderson d9175b871c hashtab.c (htab_size): Move to top of file; mark inline.
* hashtab.c (htab_size): Move to top of file; mark inline.
        (htab_elements): Likewise.
        (htab_mod, htab_mod_m2): New.
        (htab_delete): Refactor htab->size and htab->entries.
        (htab_empty): Likewise.
        (find_empty_slot_for_expand): Use htab_size, htab_mod, htab_mod_m2.
        (htab_find_with_hash, htab_find_slot_with_hash): Likewise.
        (htab_clear_slot): Use htab_size, htab_elements.
        (htab_traverse_noresize, htab_traverse): Likewise.

From-SVN: r80278
2004-03-31 17:40:43 -08:00
Josef Zlomek e0432c1c14 hashtab.c (htab_find_slot_with_hash): Decrease n_deleted instead of increasing n_elements when inserting to deleted slot.
* hashtab.c (htab_find_slot_with_hash): Decrease n_deleted
	instead of increasing n_elements when inserting to deleted slot.

From-SVN: r73090
2003-10-30 17:00:51 +00:00
Dara Hazeghi cf8e4b7876 configure.in: Add check for malloc.h needed by m68k for function free().
* configure.in: Add check for malloc.h needed by
m68k for function free().
* configure: Regenerated.
* config.in: Add HAVE_MALLOC_H.
* hashtab.c: include malloc.h were available for
free().

From-SVN: r68213
2003-06-19 15:04:03 -04:00
Jason Merrill 9d70d418db s/burtle/iterative
From-SVN: r66577
2003-05-07 16:30:32 -04:00
Jason Merrill 5cc5a0d00d hashtab.c (burtle_hash): New fn.
libiberty/
        * hashtab.c (burtle_hash): New fn.
        * configure.in: Add AC_C_BIGENDIAN_CROSS.
        * aclocal.m4: Include accross.m4.
        * configure, config.in: Regenerate.
include/
        * hashtab.h (burtle_hash): Prototype.
        (burtle_hash_object): New macro.

From-SVN: r66565
2003-05-07 14:07:58 -04:00
Kaveh R. Ghazi c9ac9147cf argv.c: Fix comments.
* argv.c: Fix comments.
	* calloc.c: Don't unnecessarily include "libiberty.h".
	(bzero): Add prototype.
	* floatformat.c: Include "ansidecl.h", rely on ANSI_PROTOTYPES.
	* getcwd.c (getcwd): Use standard definition to avoid conflicts
	with system headers.
	* hashtab.c (htab_traverse): Delete unused variables.
	* rename.c: Include "ansidecl.h".
	(rename): Use standard definition to avoid conflicts with system
	headers.
	* strsignal.c: Rely on ANSI_PROTOTYPES.
	* strstr.c: Check GNUC >= 2, not GNUC == 2.
	* vfprintf.c: Include "ansidecl.h", rely on ANSI_PROTOTYPES.
	* vprintf.c: Include "ansidecl.h" earlier, rely on
	ANSI_PROTOTYPES.
	* vsprintf.c: Include "ansidecl.h" earlier, rely on
	ANSI_PROTOTYPES and possibly include <stdarg.h>.

	* Makefile.in: Regenerate dependencies.

From-SVN: r65659
2003-04-15 20:36:33 +00:00
Jan Hubicka dbccdc4211 ggc-common.c (ggc_mark_roots): Use htab_traverse_noresize.
* ggc-common.c (ggc_mark_roots): Use htab_traverse_noresize.

	* hashtab.h (htab_traverse_noresize): Declare.

	* hashtab.c (htab_traverse_noresize): Break out from ...
	* hashtab.c (htab_traverse): ... here.

From-SVN: r64496
2003-03-17 17:59:58 +00:00
Jan Hubicka cd22e4af59 * hashtab.c (htab_expand): Fix warning.
From-SVN: r64249
2003-03-12 16:43:21 +00:00
Jan Hubicka 0a8e3de3c8 hashtab.c (htab_expand): Compute the size of hashtable based on the number of elements actually used.
* hashtab.c (htab_expand): Compute the size of hashtable based
	on the number of elements actually used.
	(htab_traverse):  Call htab_expand when table is too empty.

From-SVN: r64246
2003-03-12 14:15:09 +00:00
Daniel Jacobowitz 74828682c7 hashtab.h (htab_alloc_with_arg, [...]): Add new types.
include/
	* hashtab.h (htab_alloc_with_arg, htab_free_with_arg): Add new types.
	(struct htab): Add alloc_arg, alloc_with_arg_f, free_with_arg_f.
	(htab_create_alloc_ex): New prototype.
	(htab_set_functions_ex): New prototype.

libiberty/
	* hashtab.c (htab_create_alloc_ex): New function.
	(hatab_set_functions_ex): New function.
	(htab_delete, htab_expand): Support alternate allocation functions.

From-SVN: r61820
2003-01-26 07:09:41 +00:00
Josef Zlomek 120cdf68d5 * hashtab.c (htab_expand): Fix allocation of new entries.
From-SVN: r61507
2003-01-20 18:41:01 +00:00
Geoffrey Keating 045b3a49ca Index: include/ChangeLog
Index: include/ChangeLog
	* hashtab.h (htab_create): Restore prototype for backward
	compatibility.
	(htab_try_create): Likewise.

Index: libiberty/ChangeLog
	* hashtab.c (htab_create): New stub function for backward
	compatibility.
	(htab_try_create): Likewise.

From-SVN: r54300
2002-06-06 03:23:27 +00:00
Geoffrey Keating e2500fedef Merge from pch-branch up to tag pch-commit-20020603.
From-SVN: r54232
2002-06-04 07:11:05 +00:00
Richard Henderson 4fc4e47839 hashtab.c (higher_prime_number): Use 7 as minimum.
* hashtab.c (higher_prime_number): Use 7 as minimum.
        (find_empty_slot_for_expand): Don't compute hash2 unless needed.
        (htab_find_slot_with_hash): Likewise.

From-SVN: r52099
2002-04-09 17:14:53 -07:00
Kaveh R. Ghazi 0be6abca22 demangle.h (demangler_engine): Const-ify.
include:
	* demangle.h (demangler_engine): Const-ify.
	* libiberty.h (buildargv): Likewise.

libiberty:
	* argv.c (buildargv, tests, main): Const-ify.
	* cp-demangle.c (operator_code): Likewise.
	* cplus-dem.c (optable, libiberty_demanglers,
	cplus_demangle_set_style, cplus_demangle_name_to_style,
	print_demangler_list): Likewise.
	* hashtab.c (higher_prime_number): Likewise.
	* strcasecmp.c (charmap): Likewise.
	* strerror.c (error_info, strerror, main): Likewise.
	* strncasecmp.c (charmap): Likewise.
	* strsignal.c (signal_info): Likewise.

From-SVN: r46060
2001-10-07 14:45:04 +00:00
Richard Henderson 0ed5305d8d Add commentary.
From-SVN: r44978
2001-08-17 12:58:05 -07:00
Richard Henderson 9e0ba68596 * hashtab.c (htab_hash_string): New.
From-SVN: r44950
2001-08-16 18:54:43 -07:00
Michael Meissner 6e8afa9980 fix typo
From-SVN: r40517
2001-03-15 21:41:13 +00:00
Michael Meissner f8a0ba8c2f Silence warning
From-SVN: r40512
2001-03-15 20:24:59 +00:00
Michael Meissner 8860ddab5d Silence warning
From-SVN: r40511
2001-03-15 20:14:33 +00:00
Mark Mitchell a4c9b97e26 hashtab.c (higher_prime_number): Use a table, rather than a seive, to find the next prime.
* hashtab.c (higher_prime_number): Use a table, rather than a
	seive, to find the next prime.

From-SVN: r37775
2000-11-27 04:23:38 +00:00
Hans-Peter Nilsson d50d20ecc8 hashtab.c (htab_expand): Change to return int.
* hashtab.c (htab_expand): Change to return int.  Use calloc or
 	xcalloc depending on htab->return_allocation_failure.  Return zero
 	if calloc fails.
	(htab_create): Update comment to cover memory allocation.
	(htab_try_create): New.
	(htab_find_slot_with_hash): Return NULL if htab_expand fails.
  	Update comment to cover this.

From-SVN: r37247
2000-11-04 07:42:53 +00:00
Hans-Peter Nilsson 35e9340fc9 (htab_create, htab_expand): Correct formatting of comment before
function.

From-SVN: r37231
2000-11-03 20:26:51 +00:00
Zack Weinberg d11ec6f0d9 hashtab.c, [...]: Include string.h if HAVE_STRING_H.
* hashtab.c, partition.c, sort.c, xmemdup.c: Include string.h
	if HAVE_STRING_H.
	* pexecute.c, xexit.c: Include stdlib.h if HAVE_STDLIB_H.
	* objalloc.c: Include config.h.  Include stdlib.h and don't
	declare malloc or free if HAVE_STDLIB_H.
	* strerror.c, strsignal.c: Include stdlib.h if HAVE_STDLIB_H,
	else declare malloc without prototype.  Include string.h if
	HAVE_STRING_H, else declare memset without prototype.  Don't
	include stddef.h.

From-SVN: r34254
2000-05-29 19:33:52 +00:00
Horst von Brand 1d2da2e1ce hashtab.c (hash_pointer): Delete low-order bits which are probably zero, also eliminate a warning on alpha.
* hashtab.c (hash_pointer): Delete low-order bits which are
	probably zero, also eliminate a warning on alpha.

From-SVN: r33934
2000-05-16 16:59:20 +00:00
Jan Hubicka 8e02c4d08d hashtab.c (htab_expand): Add prototype.
* hashtab.c (htab_expand): Add prototype.
	(find_empty_slot_for_expand): Likewise.

From-SVN: r33487
2000-04-27 14:59:55 +00:00
Kaveh R. Ghazi 4feeaae33e hashtab.c (hash_pointer, eq_pointer): Make definition static to match prototype.
* hashtab.c (hash_pointer, eq_pointer): Make definition static to
       match prototype.
       (htab_expand): Cast the return value of xcalloc.

From-SVN: r33391
2000-04-24 22:29:09 +00:00
Mark Mitchell 18a94a2f75 hashtab.h (hash_pointer): Declare.
* hashtab.h (hash_pointer): Declare.
	(eq_pointer): Likewise.

	* hashtab.c (hash_pointer): New function.
	(eq_pointer): Likewise.
	(htab_hash_pointer): New variable.
	(htab_eq_pointer): Likewise.

From-SVN: r33372
2000-04-24 07:29:11 +00:00
Richard Kenner e38992e8d3 conflict.c (conflict_graph_add): Pass enum type to htab_find_slot.
* gcc/conflict.c (conflict_graph_add): Pass enum type to
	htab_find_slot.
	* gcc/cpperror.c (hashtab.h): Now include.
	* gcc/cppexp.c (hashtab.h): Likewise.
	* gcc/cpplex.c (hashtab.h): Likewise.
	* gcc/cppfiles.c (hashtab.h): Likewise.
	(find_include_file, _cpp_calc_hash, cpp_read_file): Pass enum type
	to htab_find_slot_with_hash.
	* gcc/cpphash.c (hashtab.h): Now include.
	(_cpp_lookup_slot): INSERT is now enum insert_option.
	* gcc/cpphash.h (_cpp_lookup_slot): Likewise.
	* gcc/cppinit.c (hashtab.h): Include earlier.
	(initialize_builtins): Pass enum to htab_find_slot.
	* gcc/cpplib.c (hashtab.h): Now include.
	(do_define, do_undef): Pass enum type to _cpp_lookup_slot.
	(do_pragma_poison, do_assert): Likewise.
	* gcc/emit-rtl.c (gen_rtx_CONST_INT): Pass enum to
	htab_find_slot_with_hash.
	* gcc/simplify-rtx.c (cselib_lookup_mem, cselib_lookup): Likewise.
	* gcc/tree.c (type_hash_add): Likewise.
	(build1): Minor cleanup.
	* include/hashtab.h (enum insert_option): New type.
	(htab_find_slot, htab_find_slot_with_hash): Use it.
	* libiberty/hashtab.c: Various minor cleanups.
	(htab_find_slot_with_hash): INSERT is now enum insert_option.
	(htab_find_slot): Likewise.

From-SVN: r33236
2000-04-18 16:42:00 -04:00
Mark Mitchell b13eb66b7d hashtab.h (hashval_t): New type.
* hashtab.h (hashval_t): New type.
	(htab_find_with_hash): Use it as an argument.
	(htab_find_slot_with_hash): Likewise.

	* hashtab.c (find_empty_slot_for_expand): Use hashval_t for hash
	codes.
	(htab_find_with_hash): Likewise.
	(htab_find_slot_with_hash): Likewise.

From-SVN: r32842
2000-03-31 07:04:37 +00:00
Zack Weinberg 0194e877a3 hashtab.c (htab_find_with_hash): Avoid calculating hash2 unless it will be used.
* hashtab.c (htab_find_with_hash): Avoid calculating hash2
	unless it will be used.  Rearrange loop for better
	optimization.
	(higher_prime_number): Add static prototype.

From-SVN: r32809
2000-03-29 19:04:54 +00:00
Bernd Schmidt 8c5d513f17 Some cleanups/additions for hashtables
From-SVN: r32536
2000-03-14 18:28:45 +00:00
Zack Weinberg 5dc9cffdfd hashtab.h (struct htab): Add del_f.
* hashtab.h (struct htab): Add del_f.
	(htab_del): New type.
	(htab_create): Add fourth argument.

	* hashtab.c (htab_create): Set del_f.
	(htab_delete, htab_empty, htab_remove_elt, htab_clear_slot):
	Use it.

From-SVN: r32459
2000-03-10 00:00:24 +00:00
Zack Weinberg 5194cf0890 hashtab.c: Remove debugging variables (all_searches, all_collisions, all_expansions).
* hashtab.c: Remove debugging variables (all_searches,
	all_collisions, all_expansions). Delete
	all_hash_table_collisions.
	(create_hash_table, delete_hash_table, empty_hash_table,
	find_hash_table_entry, remove_element_from_hash_table_entry,
	clear_hash_table_slot, traverse_hash_table, hash_table_size,
	hash_table_elements_number, hash_table_collisions): Rename to:
	htab_create, htab_delete, htab_empty, htab_find_slot,
	htab_remove_elt, htab_clear_slot, htab_traverse, htab_size,
	htab_elements, htab_collisions.
	(htab_find): New function, handles common case where you don't
	plan to add or delete an entry.
	(htab_expand): Don't create a whole new table, just a new
	entry vector.
	(htab_find_slot): Simplify logic.

	* hashtab.h (hash_table_t): Rename to htab_t.
	(struct hash_table): Rename to struct htab.  Shorten element
	names.  Reorder elements by size.
	(htab_hash, htab_eq, htab_trav): New typedefs for the callback
	function pointers.
	(hash_table_entry_t): Discard; just use void * for element
	type.

From-SVN: r32437
2000-03-08 23:44:29 +00:00
Philippe De Muyter 6de9b8ff12 * hashtab.c (sys/types.h): File included.
From-SVN: r30683
1999-11-28 00:58:37 -07:00
Jeffrey A Law 36dd3a44a3 * hashtab.c: Include stdio.h.
From-SVN: r30475
1999-11-10 09:45:34 -07:00
Jeffrey A Law 6e30047279 * hashtab.c (traverse_hash_table): Protect prototype with PARAMS.
From-SVN: r30453
1999-11-08 09:26:37 -07:00
Zack Weinberg ed38f5d5d8 hashtab.c (find_hash_table_entry): When returning a DELETED_ENTRY slot, change it to EMPTY_ENTRY first.
1999-10-23 08:51 -0700  Zack Weinberg  <zack@bitmover.com>

	* hashtab.c (find_hash_table_entry): When returning a
	DELETED_ENTRY slot, change it to EMPTY_ENTRY first.
	(clear_hash_table_slot): New function which deletes an entry
	by its position in the table, not its value.
	(traverse_hash_table): New function which calls a hook
	function for every live entry in the table.

	* hashtab.h: Give hash_table_t a struct tag.  Add prototypes
	for clear_hash_table_slot and traverse_hash_table.  Correct
	prototype of all_hash_table_collisions.

From-SVN: r30138
1999-10-23 15:56:52 +00:00
Vladimir Makarov a2f945c649 Makefile.in (CFILES): Add hashtab.c
* Makefile.in (CFILES): Add hashtab.c
        (REQUIRED_OFILES): Add hashtab.o
        (hashtab.o): Add dependencies.
        * hashtab.c: New file

From-SVN: r30012
1999-10-15 01:50:25 -06:00