예제 #1
0
파일: list.c 프로젝트: bubuker/keggle_santa
List* list_new_entry(const Entry* entry)
{
   ListData data;
   
   assert(entry_is_valid(entry));

   data.entry = entry_copy(entry);

   return list_new(LIST_ENTRY, &data);
}
예제 #2
0
파일: list.c 프로젝트: bubuker/keggle_santa
void list_insert_entry(List* list, const Entry* entry)
{
   ListData data;

   assert(list_is_valid(list));
   assert(entry_is_valid(entry));
   assert(list->type == LIST_ENTRY);

   data.entry = entry_copy(entry);

   list_insert_data(list, &data);
}
예제 #3
0
/* Entry is eaten.
 * No check is done if entry->tuple is a member of sym->set !
 * This has to be done before.
 */
void symbol_add_entry(Symbol* sym, Entry* entry)
{
   const Tuple* tuple;
   
   assert(symbol_is_valid(sym));
   assert(entry_is_valid(entry));
   
   assert(sym->used <= sym->size);
   
   if (sym->used == sym->size)
   {
      sym->size   += sym->extend;
      sym->extend += sym->extend;
      sym->entry   = realloc(
         sym->entry, (size_t)sym->size * sizeof(*sym->entry));
      
      assert(sym->entry != NULL);
   }
   assert(sym->used < sym->size);

   tuple = entry_get_tuple(entry);

   /* There is no index set for the internal symbol.
    */
   assert(!strcmp(sym->name, SYMBOL_NAME_INTERNAL) || set_lookup(sym->set, tuple));

   if (hash_has_entry(sym->hash, tuple))
   {
      if (stmt_trigger_warning(166))
      {
         fprintf(stderr, "--- Warning 166: Duplicate element ");
         tuple_print(stderr, tuple);
         fprintf(stderr, " for symbol %s rejected\n", sym->name);
      }
      entry_free(entry);
   }
   else
   {
      /* Falls noch nicht geschehen, legen wir hier den Typ des
       * Symbols fest.
       */
      if ((sym->type == SYM_ERR) && (sym->used == 0))
         sym->type = entry_get_type(entry);

      assert(sym->type != SYM_ERR);
      
      hash_add_entry(sym->hash, entry);
      
      sym->entry[sym->used] = entry;      
      sym->used++;
   }
}
예제 #4
0
파일: memattr.c 프로젝트: 513855417/linux
/*
 * To be called after the EFI page tables have been populated. If a memory
 * attributes table is available, its contents will be used to update the
 * mappings with tightened permissions as described by the table.
 * This requires the UEFI memory map to have already been populated with
 * virtual addresses.
 */
int __init efi_memattr_apply_permissions(struct mm_struct *mm,
					 efi_memattr_perm_setter fn)
{
	efi_memory_attributes_table_t *tbl;
	int i, ret;

	if (tbl_size <= sizeof(*tbl))
		return 0;

	/*
	 * We need the EFI memory map to be setup so we can use it to
	 * lookup the virtual addresses of all entries in the  of EFI
	 * Memory Attributes table. If it isn't available, this
	 * function should not be called.
	 */
	if (WARN_ON(!efi_enabled(EFI_MEMMAP)))
		return 0;

	tbl = memremap(efi.mem_attr_table, tbl_size, MEMREMAP_WB);
	if (!tbl) {
		pr_err("Failed to map EFI Memory Attributes table @ 0x%lx\n",
		       efi.mem_attr_table);
		return -ENOMEM;
	}

	if (efi_enabled(EFI_DBG))
		pr_info("Processing EFI Memory Attributes table:\n");

	for (i = ret = 0; ret == 0 && i < tbl->num_entries; i++) {
		efi_memory_desc_t md;
		unsigned long size;
		bool valid;
		char buf[64];

		valid = entry_is_valid((void *)tbl->entry + i * tbl->desc_size,
				       &md);
		size = md.num_pages << EFI_PAGE_SHIFT;
		if (efi_enabled(EFI_DBG) || !valid)
			pr_info("%s 0x%012llx-0x%012llx %s\n",
				valid ? "" : "!", md.phys_addr,
				md.phys_addr + size - 1,
				efi_md_typeattr_format(buf, sizeof(buf), &md));

		if (valid)
			ret = fn(mm, &md);
	}
	memunmap(tbl);
	return ret;
}
예제 #5
0
파일: hash.c 프로젝트: aimanqais/gerardus
void hash_add_entry(Hash* hash, const Entry* entry)
{
   HElem*       he = blk_alloc(sizeof(*he));
   const Tuple* tuple;
   unsigned int hcode;

   assert(hash_is_valid(hash));
   assert(entry_is_valid(entry));
   assert(hash->type == HASH_ENTRY);
   assert(he != NULL);
   
   tuple               = entry_get_tuple(entry);
   hcode               = tuple_hash(tuple) % hash->size;
   he->value.entry     = entry;
   he->next            = hash->bucket[hcode];
   hash->bucket[hcode] = he;
   hash->elems++;
}
예제 #6
0
파일: hash.c 프로젝트: aimanqais/gerardus
/* Liefert NULL wenn nicht gefunden.
 */
const Entry* hash_lookup_entry(const Hash* hash, const Tuple* tuple)
{
   unsigned int hcode = tuple_hash(tuple) % hash->size;
   HElem*       he;
   
   assert(hash_is_valid(hash));
   assert(tuple_is_valid(tuple));

   for(he = hash->bucket[hcode]; he != NULL; he = he->next)
      if (!entry_cmp(he->value.entry, tuple))
         break;

   if (he == NULL)
      return NULL;

   assert(he != NULL);

   assert(entry_is_valid(he->value.entry));

   return he->value.entry;
}