Example #1
0
static hashval_t
lto_symtab_entry_hash (const void *p)
{
  const struct lto_symtab_entry_def *base =
    (const struct lto_symtab_entry_def *) p;
  return IDENTIFIER_HASH_VALUE (base->id);
}
Example #2
0
static void
objc_map_private_resize (objc_map_t map, size_t new_number_of_slots)
{
  tree *old_slots = map->slots;
  tree *old_values = map->values;
  size_t i, old_number_of_slots = map->number_of_slots;
  
  if (new_number_of_slots < (map->number_of_non_empty_slots))
    new_number_of_slots = 2 * map->number_of_non_empty_slots;

  new_number_of_slots = next_power_of_two (new_number_of_slots);
  
  map->number_of_slots = new_number_of_slots;
  map->mask = map->number_of_slots - 1;
  map->max_number_of_non_empty_slots = (map->number_of_slots * map->maximum_load_factor) / 100;


  map->slots = (tree *)ggc_internal_cleared_vec_alloc (map->number_of_slots, sizeof (tree));
  map->values = (tree *)ggc_internal_cleared_vec_alloc (map->number_of_slots, sizeof (tree));

  if (map->slots == NULL)
    OUT_OF_MEMORY;

  if (map->values == NULL)
    OUT_OF_MEMORY;

  for (i = 0; i < old_number_of_slots; i++)
    if (old_slots[i] != OBJC_MAP_PRIVATE_EMPTY_SLOT)
      {
	size_t k = IDENTIFIER_HASH_VALUE (old_slots[i]) & map->mask;
	
	if (map->slots[k] == OBJC_MAP_PRIVATE_EMPTY_SLOT)
	  {
	    map->slots[k] = old_slots[i];
	    map->values[k] = old_values[i];
	  }
	else
	  {
	    size_t j = 1;
	    while (1)
	      {
		k = (k + j) & map->mask;
		if (map->slots[k] == OBJC_MAP_PRIVATE_EMPTY_SLOT)
		  {
		    map->slots[k] = old_slots[i];
		    map->values[k] = old_values[i];
		    break;
		  }
		j++;
	      }
	  }
      }

  ggc_free (old_slots);
  ggc_free (old_values);
}