htab package insert flag

Richard Kenner kenner@vlsi1.ultra.nyu.edu
Tue Apr 18 13:43:00 GMT 2000


As requested, I changed it to be an enum:

Tue Apr 18 14:16:47 2000  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* 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.

*** gcc/conflict.c	2000/04/18 18:14:10	1.3
--- gcc/conflict.c	2000/04/18 19:41:50
*************** conflict_graph_add (graph, reg1, reg2)
*** 207,211 ****
    dummy.smaller = smaller;
    dummy.larger = larger;
!   slot = htab_find_slot (graph->arc_hash_table, (void *) &dummy, 1);
    
    /* If the conflict is already there, do nothing.  */
--- 207,211 ----
    dummy.smaller = smaller;
    dummy.larger = larger;
!   slot = htab_find_slot (graph->arc_hash_table, (void *) &dummy, INSERT);
    
    /* If the conflict is already there, do nothing.  */
*** gcc/cpperror.c	2000/04/14 23:29:43	1.31
--- gcc/cpperror.c	2000/04/18 19:41:52
*************** Foundation, 59 Temple Place - Suite 330,
*** 26,29 ****
--- 26,30 ----
  #include "config.h"
  #include "system.h"
+ #include "hashtab.h"
  #include "cpplib.h"
  #include "cpphash.h"
*** gcc/cppexp.c	2000/04/18 06:43:40	1.50
--- gcc/cppexp.c	2000/04/18 19:41:55
*************** Written by Per Bothner 1994.  */
*** 28,31 ****
--- 23,27 ----
  #include "system.h"
  #include "cpplib.h"
+ #include "hashtab.h"
  #include "cpphash.h"
  
*** gcc/cppfiles.c	2000/04/17 00:54:25	1.55
--- gcc/cppfiles.c	2000/04/18 19:42:01
*************** GNU General Public License for more deta
*** 19,33 ****
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
! Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  
-  In other words, you are welcome to use, share and improve this program.
-  You are forbidden to forbid anyone else to use, share and improve
-  what you give them.   Help stamp out software-hoarding!  */
- 
  #include "config.h"
  #include "system.h"
  #include "cpplib.h"
  #include "cpphash.h"
- #include "hashtab.h"
  #include "intl.h"
  #include "mkdeps.h"
--- 19,29 ----
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
! Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
  #include "config.h"
  #include "system.h"
+ #include "hashtab.h"
  #include "cpplib.h"
  #include "cpphash.h"
  #include "intl.h"
  #include "mkdeps.h"
*************** find_include_file (pfile, fname, search_
*** 264,269 ****
    path = (fname[0] == '/') ? ABSOLUTE_PATH : search_start;
    slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files,
! 					      (const void *)&dummy,
! 					      dummy.hash, 1);
  
    if (*slot && (ih = redundant_include_p (pfile, *slot, path)))
--- 260,265 ----
    path = (fname[0] == '/') ? ABSOLUTE_PATH : search_start;
    slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files,
! 					      (const void *) &dummy,
! 					      dummy.hash, INSERT);
  
    if (*slot && (ih = redundant_include_p (pfile, *slot, path)))
*************** _cpp_fake_ihash (pfile, fname)
*** 334,339 ****
    dummy.hash = _cpp_calc_hash (fname, strlen (fname));
    slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files,
! 					      (const void *)&dummy,
! 					      dummy.hash, 1);
    if (*slot)
      return (*slot)->name;
--- 330,335 ----
    dummy.hash = _cpp_calc_hash (fname, strlen (fname));
    slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files,
! 					      (const void *) &dummy,
! 					      dummy.hash, INSERT);
    if (*slot)
      return (*slot)->name;
*************** cpp_read_file (pfile, fname)
*** 671,678 ****
    slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files,
  					      (const void *) &dummy,
! 					      dummy.hash, 1);
    if (*slot && (ih = redundant_include_p (pfile, *slot, ABSOLUTE_PATH)))
      {
!       if (ih == (IHASH *)-1)
  	return 1;  /* Already included.  */
      }
--- 667,674 ----
    slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files,
  					      (const void *) &dummy,
! 					      dummy.hash, INSERT);
    if (*slot && (ih = redundant_include_p (pfile, *slot, ABSOLUTE_PATH)))
      {
!       if (ih == (IHASH *) -1)
  	return 1;  /* Already included.  */
      }
*** gcc/cpphash.c	2000/04/18 06:43:40	1.67
--- gcc/cpphash.c	2000/04/18 19:42:11
*************** Foundation, 59 Temple Place - Suite 330,
*** 27,32 ****
  #include "system.h"
  #include "cpplib.h"
- #include "cpphash.h"
  #include "hashtab.h"
  #undef abort
  
--- 27,33 ----
  #include "system.h"
  #include "cpplib.h"
  #include "hashtab.h"
+ #include "cpphash.h"
+ 
  #undef abort
  
*************** _cpp_lookup (pfile, name, len)
*** 201,204 ****
--- 202,206 ----
  
  /* Find the hashtable slot for name "name".  Used to insert or delete.  */
+ 
  HASHNODE **
  _cpp_lookup_slot (pfile, name, len, insert, hash)
*************** _cpp_lookup_slot (pfile, name, len, inse
*** 206,210 ****
       const U_CHAR *name;
       int len;
!      int insert;
       unsigned long *hash;
  {
--- 208,212 ----
       const U_CHAR *name;
       int len;
!      enum insert_option insert;
       unsigned long *hash;
  {
*************** _cpp_lookup_slot (pfile, name, len, inse
*** 215,219 ****
    if (len < 0)
      {
!       for (bp = name; is_idchar (*bp); bp++);
        len = bp - name;
      }
--- 217,223 ----
    if (len < 0)
      {
!       for (bp = name; is_idchar (*bp); bp++)
! 	;
! 
        len = bp - name;
      }
*************** _cpp_lookup_slot (pfile, name, len, inse
*** 224,228 ****
  
    slot = (HASHNODE **) htab_find_slot_with_hash (pfile->hashtab,
! 						 (void *)&dummy,
  						 dummy.hash, insert);
    if (insert)
--- 228,232 ----
  
    slot = (HASHNODE **) htab_find_slot_with_hash (pfile->hashtab,
! 						 (void *) &dummy,
  						 dummy.hash, insert);
    if (insert)
*** gcc/cpphash.h	2000/04/18 06:43:40	1.33
--- gcc/cpphash.h	2000/04/18 19:42:14
*************** extern HASHNODE *_cpp_lookup		PARAMS ((c
*** 275,279 ****
  						 const U_CHAR *, int));
  extern HASHNODE **_cpp_lookup_slot	PARAMS ((cpp_reader *,
! 						 const U_CHAR *, int, int,
  						 unsigned long *));
  extern void _cpp_free_definition	PARAMS ((DEFINITION *));
--- 275,280 ----
  						 const U_CHAR *, int));
  extern HASHNODE **_cpp_lookup_slot	PARAMS ((cpp_reader *,
! 						 const U_CHAR *, int,
! 						 enum insert_option,
  						 unsigned long *));
  extern void _cpp_free_definition	PARAMS ((DEFINITION *));
*** gcc/cppinit.c	2000/04/17 00:54:25	1.75
--- gcc/cppinit.c	2000/04/18 19:42:20
*************** Foundation, 59 Temple Place - Suite 330,
*** 22,26 ****
  #include "config.h"
  #include "system.h"
! 
  #include "cpplib.h"
  #include "cpphash.h"
--- 22,26 ----
  #include "config.h"
  #include "system.h"
! #include "hashtab.h"
  #include "cpplib.h"
  #include "cpphash.h"
*************** Foundation, 59 Temple Place - Suite 330,
*** 29,33 ****
  #include "intl.h"
  #include "version.h"
- #include "hashtab.h"
  #include "mkdeps.h"
  
--- 29,32 ----
*************** initialize_builtins (pfile)
*** 684,688 ****
  			       _cpp_calc_hash (b->name, len));
        hp->value.cpval = val;
!       *(htab_find_slot (pfile->hashtab, (void *)hp, 1)) = hp;
  
        if ((b->flags & DUMP) && CPP_OPTION (pfile, debug_output))
--- 683,687 ----
  			       _cpp_calc_hash (b->name, len));
        hp->value.cpval = val;
!       *(htab_find_slot (pfile->hashtab, (void *) hp, INSERT)) = hp;
  
        if ((b->flags & DUMP) && CPP_OPTION (pfile, debug_output))
*** gcc/cpplex.c	2000/04/18 18:52:14	1.17
--- gcc/cpplex.c	2000/04/18 19:42:28
*************** Foundation, 59 Temple Place - Suite 330,
*** 23,26 ****
--- 23,27 ----
  #include "system.h"
  #include "intl.h"
+ #include "hashtab.h"
  #include "cpplib.h"
  #include "cpphash.h"
*** gcc/cpplib.c	2000/04/18 06:43:40	1.147
--- gcc/cpplib.c	2000/04/18 19:42:39
*************** Foundation, 59 Temple Place - Suite 330,
*** 23,26 ****
--- 23,27 ----
  #include "system.h"
  
+ #include "hashtab.h"
  #include "cpplib.h"
  #include "cpphash.h"
*************** do_define (pfile)
*** 393,397 ****
      }
  
!   slot = _cpp_lookup_slot (pfile, sym, len, 1, &hash);
    if (*slot)
      {
--- 394,398 ----
      }
  
!   slot = _cpp_lookup_slot (pfile, sym, len, INSERT, &hash);
    if (*slot)
      {
*************** do_undef (pfile)
*** 771,775 ****
    CPP_SET_WRITTEN (pfile, here);
  
!   slot = _cpp_lookup_slot (pfile, name, len, 0, 0);
    if (slot)
      {
--- 772,776 ----
    CPP_SET_WRITTEN (pfile, here);
  
!   slot = _cpp_lookup_slot (pfile, name, len, NO_INSERT, 0);
    if (slot)
      {
*************** do_pragma_poison (pfile)
*** 1029,1033 ****
        p = pfile->token_buffer + written;
        len = strlen (p);
!       slot = _cpp_lookup_slot (pfile, p, len, 1, &hash);
        if (*slot)
  	{
--- 1030,1034 ----
        p = pfile->token_buffer + written;
        len = strlen (p);
!       slot = _cpp_lookup_slot (pfile, p, len, INSERT, &hash);
        if (*slot)
  	{
*************** do_assert (pfile)
*** 1587,1591 ****
    sym = pfile->token_buffer + old_written;
    blen = (U_CHAR *) strchr (sym, '(') - sym;
!   tslot = _cpp_lookup_slot (pfile, sym, tlen, 1, &thash);
    if (*tslot)
      {
--- 1588,1592 ----
    sym = pfile->token_buffer + old_written;
    blen = (U_CHAR *) strchr (sym, '(') - sym;
!   tslot = _cpp_lookup_slot (pfile, sym, tlen, INSERT, &thash);
    if (*tslot)
      {
*************** do_assert (pfile)
*** 1594,1598 ****
      }
  
!   bslot = _cpp_lookup_slot (pfile, sym, blen, 1, &bhash);
    if (! *bslot)
      {
--- 1595,1599 ----
      }
  
!   bslot = _cpp_lookup_slot (pfile, sym, blen, INSERT, &bhash);
    if (! *bslot)
      {
*** gcc/emit-rtl.c	2000/04/15 11:16:56	1.126
--- gcc/emit-rtl.c	2000/04/18 19:43:02
*************** gen_rtx_CONST_INT (mode, arg)
*** 249,253 ****
  
    /* Look up the CONST_INT in the hash table.  */
!   slot = htab_find_slot_with_hash (const_int_htab, &arg, (hashval_t) arg, 1);
    if (*slot == 0)
      {
--- 249,254 ----
  
    /* Look up the CONST_INT in the hash table.  */
!   slot = htab_find_slot_with_hash (const_int_htab, &arg,
! 				   (hashval_t) arg, INSERT);
    if (*slot == 0)
      {
*** gcc/simplify-rtx.c	2000/04/18 18:14:10	1.12
--- gcc/simplify-rtx.c	2000/04/18 19:43:16
*************** cselib_lookup_mem (x, create)
*** 2663,2667 ****
    mem_elt = new_cselib_val (++next_unknown_value, GET_MODE (x));
    add_mem_for_addr (addr, mem_elt, x);
!   slot = htab_find_slot_with_hash (hash_table, x, mem_elt->value, 1);
    *slot = mem_elt;
    return mem_elt;
--- 2663,2667 ----
    mem_elt = new_cselib_val (++next_unknown_value, GET_MODE (x));
    add_mem_for_addr (addr, mem_elt, x);
!   slot = htab_find_slot_with_hash (hash_table, x, mem_elt->value, INSERT);
    *slot = mem_elt;
    return mem_elt;
*************** cselib_lookup (x, mode, create)
*** 2783,2787 ****
        e->locs = new_elt_loc_list (e->locs, x);
        REG_VALUES (i) = new_elt_list (REG_VALUES (i), e);
!       slot = htab_find_slot_with_hash (hash_table, x, e->value, 1);
        *slot = e;
        return e;
--- 2783,2787 ----
        e->locs = new_elt_loc_list (e->locs, x);
        REG_VALUES (i) = new_elt_list (REG_VALUES (i), e);
!       slot = htab_find_slot_with_hash (hash_table, x, e->value, INSERT);
        *slot = e;
        return e;
*************** cselib_lookup (x, mode, create)
*** 2796,2800 ****
      return 0;
  
!   slot = htab_find_slot_with_hash (hash_table, x, hashval, create);
    if (slot == 0)
      return 0;
--- 2796,2801 ----
      return 0;
  
!   slot = htab_find_slot_with_hash (hash_table, x, hashval,
! 				   create ? INSERT : NO_INSERT);
    if (slot == 0)
      return 0;
*** gcc/tree.c	2000/04/15 16:59:10	1.138
--- gcc/tree.c	2000/04/18 19:43:45
*************** build1 (code, type, node)
*** 3401,3409 ****
  
    TREE_OPERAND (t, 0) = node;
!   if (node && first_rtl_op (code) != 0)
!     {
!       if (TREE_SIDE_EFFECTS (node))
! 	TREE_SIDE_EFFECTS (t) = 1;
!     }
  
    switch (code)
--- 3401,3406 ----
  
    TREE_OPERAND (t, 0) = node;
!   if (node && first_rtl_op (code) != 0 && TREE_SIDE_EFFECTS (node))
!     TREE_SIDE_EFFECTS (t) = 1;
  
    switch (code)
*************** type_hash_add (hashcode, type)
*** 4083,4088 ****
    h->hash = hashcode;
    h->type = type;
!   loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, 1);
!   *(struct type_hash**)loc = h;
  }
  
--- 4080,4085 ----
    h->hash = hashcode;
    h->type = type;
!   loc = htab_find_slot_with_hash (type_hash_table, h, hashcode, INSERT);
!   *(struct type_hash**) loc = h;
  }
  
*** include/hashtab.h	2000/03/31 07:04:37	1.6
--- include/hashtab.h	2000/04/18 19:44:31
*************** struct htab
*** 103,106 ****
--- 103,109 ----
  typedef struct htab *htab_t;
  
+ /* An enum saying whether we insert into the hash table or not.  */
+ enum insert_option {NO_INSERT, INSERT};
+ 
  /* The prototypes of the package functions. */
  
*************** extern void	htab_empty	PARAMS ((htab_t))
*** 111,119 ****
  
  extern void    *htab_find	PARAMS ((htab_t, const void *));
! extern void   **htab_find_slot	PARAMS ((htab_t, const void *, int));
! extern void    *htab_find_with_hash		PARAMS ((htab_t, const void *,
! 							 hashval_t));
! extern void   **htab_find_slot_with_hash	PARAMS ((htab_t, const void *,
! 							 hashval_t, int));
  extern void	htab_clear_slot	PARAMS ((htab_t, void **));
  extern void	htab_remove_elt	PARAMS ((htab_t, void *));
--- 114,124 ----
  
  extern void    *htab_find	PARAMS ((htab_t, const void *));
! extern void   **htab_find_slot	PARAMS ((htab_t, const void *,
! 					 enum insert_option));
! extern void    *htab_find_with_hash	  PARAMS ((htab_t, const void *,
! 						   hashval_t));
! extern void   **htab_find_slot_with_hash  PARAMS ((htab_t, const void *,
! 						   hashval_t,
! 						   enum insert_option));
  extern void	htab_clear_slot	PARAMS ((htab_t, void **));
  extern void	htab_remove_elt	PARAMS ((htab_t, void *));
*** libiberty/hashtab.c	2000/03/31 07:04:37	1.10
--- libiberty/hashtab.c	2000/04/18 19:44:34
*************** static unsigned long higher_prime_number
*** 59,63 ****
  
  /* The following function returns the nearest prime number which is
!    greater than a given source number. */
  
  static unsigned long
--- 59,63 ----
  
  /* The following function returns the nearest prime number which is
!    greater than a given source number, N. */
  
  static unsigned long
*************** higher_prime_number (n)
*** 67,84 ****
    unsigned long i;
  
!   n |= 0x01;  /* Force N to be odd.  */
    if (n < 9)
!     return n; /* All odd numbers < 9 are prime.  */
  
   next:
!   n += 2;
!   i = 3;
!   do
!     {
!       if (n % i == 0)
! 	goto next;
!       i += 2;
!     }
!   while ((i * i) <= n);
  
    return n;
--- 67,88 ----
    unsigned long i;
  
!   /* Ensure we have a larger number and then force to odd.  */
!   n++;  
!   n |= 0x01; 
! 
!   /* All odd numbers < 9 are prime.  */
    if (n < 9)
!     return n;
! 
!   /* Otherwise find the next prime using a sieve.  */
  
   next:
! 
!   for (i = 3; i * i <= n; i += 2)
!     if (n % i == 0)
!       {
! 	 n += 2;
! 	 goto next;
!        }
  
    return n;
*************** htab_delete (htab)
*** 117,127 ****
  {
    int i;
    if (htab->del_f)
      for (i = htab->size - 1; i >= 0; i--)
!       {
! 	if (htab->entries[i] != EMPTY_ENTRY
! 	    && htab->entries[i] != DELETED_ENTRY)
! 	  (*htab->del_f) (htab->entries[i]);
!       }
  
    free (htab->entries);
--- 121,130 ----
  {
    int i;
+ 
    if (htab->del_f)
      for (i = htab->size - 1; i >= 0; i--)
!       if (htab->entries[i] != EMPTY_ENTRY
! 	  && htab->entries[i] != DELETED_ENTRY)
! 	(*htab->del_f) (htab->entries[i]);
  
    free (htab->entries);
*************** htab_empty (htab)
*** 136,146 ****
  {
    int i;
    if (htab->del_f)
      for (i = htab->size - 1; i >= 0; i--)
!       {
! 	if (htab->entries[i] != EMPTY_ENTRY
! 	    && htab->entries[i] != DELETED_ENTRY)
! 	  (*htab->del_f) (htab->entries[i]);
!       }
  
    memset (htab->entries, 0, htab->size * sizeof (void *));
--- 139,148 ----
  {
    int i;
+ 
    if (htab->del_f)
      for (i = htab->size - 1; i >= 0; i--)
!       if (htab->entries[i] != EMPTY_ENTRY
! 	  && htab->entries[i] != DELETED_ENTRY)
! 	(*htab->del_f) (htab->entries[i]);
  
    memset (htab->entries, 0, htab->size * sizeof (void *));
*************** htab_empty (htab)
*** 153,156 ****
--- 155,159 ----
     This function also assumes there are no deleted entries in the table.
     HASH is the hash value for the element to be inserted.  */
+ 
  static void **
  find_empty_slot_for_expand (htab, hash)
*************** find_empty_slot_for_expand (htab, hash)
*** 165,172 ****
      {
        void **slot = htab->entries + index;
        if (*slot == EMPTY_ENTRY)
  	return slot;
! 
!       if (*slot == DELETED_ENTRY)
  	abort ();
  
--- 168,175 ----
      {
        void **slot = htab->entries + index;
+ 
        if (*slot == EMPTY_ENTRY)
  	return slot;
!       else if (*slot == DELETED_ENTRY)
  	abort ();
  
*************** htab_expand (htab)
*** 204,215 ****
--- 207,222 ----
      {
        void *x = *p;
+ 
        if (x != EMPTY_ENTRY && x != DELETED_ENTRY)
  	{
  	  void **q = find_empty_slot_for_expand (htab, (*htab->hash_f) (x));
+ 
  	  *q = x;
  	}
+ 
        p++;
      }
    while (p < olimit);
+ 
    free (oentries);
  }
*************** htab_find_with_hash (htab, element, hash
*** 256,259 ****
--- 263,267 ----
  /* Like htab_find_slot_with_hash, but compute the hash value from the
     element.  */
+ 
  void *
  htab_find (htab, element)
*************** htab_find_slot_with_hash (htab, element,
*** 275,279 ****
       const void *element;
       hashval_t hash;
!      int insert;
  {
    void **first_deleted_slot;
--- 283,287 ----
       const void *element;
       hashval_t hash;
!      enum insert_option insert;
  {
    void **first_deleted_slot;
*************** htab_find_slot_with_hash (htab, element,
*** 282,286 ****
    size_t size;
  
!   if (insert && htab->size * 3 <= htab->n_elements * 4)
      htab_expand (htab);
  
--- 290,294 ----
    size_t size;
  
!   if (insert == INSERT && htab->size * 3 <= htab->n_elements * 4)
      htab_expand (htab);
  
*************** htab_find_slot_with_hash (htab, element,
*** 297,301 ****
        if (entry == EMPTY_ENTRY)
  	{
! 	  if (!insert)
  	    return NULL;
  
--- 305,309 ----
        if (entry == EMPTY_ENTRY)
  	{
! 	  if (insert == NO_INSERT)
  	    return NULL;
  
*************** htab_find_slot_with_hash (htab, element,
*** 316,324 ****
  	    first_deleted_slot = &htab->entries[index];
  	}
!       else
! 	{
! 	  if ((*htab->eq_f) (entry, element))
! 	    return &htab->entries[index];
! 	}
        
        htab->collisions++;
--- 324,329 ----
  	    first_deleted_slot = &htab->entries[index];
  	}
!       else  if ((*htab->eq_f) (entry, element))
! 	return &htab->entries[index];
        
        htab->collisions++;
*************** htab_find_slot_with_hash (htab, element,
*** 331,339 ****
  /* Like htab_find_slot_with_hash, but compute the hash value from the
     element.  */
  void **
  htab_find_slot (htab, element, insert)
       htab_t htab;
       const void *element;
!      int insert;
  {
    return htab_find_slot_with_hash (htab, element, (*htab->hash_f) (element),
--- 336,345 ----
  /* Like htab_find_slot_with_hash, but compute the hash value from the
     element.  */
+ 
  void **
  htab_find_slot (htab, element, insert)
       htab_t htab;
       const void *element;
!      enum insert_option insert;
  {
    return htab_find_slot_with_hash (htab, element, (*htab->hash_f) (element),
*************** htab_remove_elt (htab, element)
*** 352,356 ****
    void **slot;
  
!   slot = htab_find_slot (htab, element, 0);
    if (*slot == EMPTY_ENTRY)
      return;
--- 358,362 ----
    void **slot;
  
!   slot = htab_find_slot (htab, element, NO_INSERT);
    if (*slot == EMPTY_ENTRY)
      return;
*************** htab_clear_slot (htab, slot)
*** 375,380 ****
--- 381,388 ----
        || *slot == EMPTY_ENTRY || *slot == DELETED_ENTRY)
      abort ();
+ 
    if (htab->del_f)
      (*htab->del_f) (*slot);
+ 
    *slot = DELETED_ENTRY;
    htab->n_deleted++;
*************** htab_traverse (htab, callback, info)
*** 392,401 ****
       void *info;
  {
!   void **slot, **limit;
!   slot = htab->entries;
!   limit = slot + htab->size;
    do
      {
        void *x = *slot;
        if (x != EMPTY_ENTRY && x != DELETED_ENTRY)
  	if (!(*callback) (slot, info))
--- 400,410 ----
       void *info;
  {
!   void **slot = htab->entries;
!   void **limit = slot + htab->size;
! 
    do
      {
        void *x = *slot;
+ 
        if (x != EMPTY_ENTRY && x != DELETED_ENTRY)
  	if (!(*callback) (slot, info))
*************** htab_traverse (htab, callback, info)
*** 405,409 ****
  }
  
! /* The following function returns current size of given hash table. */
  
  size_t
--- 414,418 ----
  }
  
! /* Return the current size of given hash table. */
  
  size_t
*************** htab_size (htab)
*** 414,419 ****
  }
  
! /* The following function returns current number of elements in given
!    hash table. */
  
  size_t
--- 423,427 ----
  }
  
! /* Return the current number of elements in given hash table. */
  
  size_t
*************** htab_elements (htab)
*** 424,429 ****
  }
  
! /* The following function returns number of percents of fixed
!    collisions during all work with given hash table. */
  
  double
--- 432,437 ----
  }
  
! /* Return the fraction of fixed collisions during all work with given
!    hash table. */
  
  double
*************** htab_collisions (htab)
*** 431,439 ****
       htab_t htab;
  {
!   int searches;
! 
!   searches = htab->searches;
!   if (searches == 0)
      return 0.0;
!   return (double)htab->collisions / (double)searches;
  }
--- 439,445 ----
       htab_t htab;
  {
!   if (htab->searches == 0)
      return 0.0;
! 
!   return (double) htab->collisions / (double) htab->searches;
  }


More information about the Gcc-patches mailing list