Remove prio_list.

* include/grub/list.h (grub_prio_list): Removed.
	(GRUB_PRIO_LIST_PRIO_MASK): Removed. All users switched to
	GRUB_COMMAND_PRIO_MASK.
	(GRUB_PRIO_LIST_FLAG_ACTIVE): Removed. All users switched to
	GRUB_COMMAND_FLAG_ACTIVE.
	(grub_prio_list_insert): Removed.
	(grub_prio_list_remove): Likewise.
	(GRUB_AS_PRIO_LIST): Likewise.
	(GRUB_AS_PRIO_LIST_P): Likewise.
	* include/grub/command.h (GRUB_COMMAND_PRIO_MASK): New define.
	(GRUB_COMMAND_FLAG_ACTIVE): Likewise.
	* grub-core/kern/list.c (grub_prio_list_insert): Remove.
	* grub-core/kern/command.c (grub_register_command_prio): Inline
	the prio_list code.
	(grub_unregister_command): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-26 22:49:24 +01:00
commit eece3349ea
8 changed files with 61 additions and 83 deletions

View file

@ -30,6 +30,9 @@ grub_register_command_prio (const char *name,
int prio)
{
grub_command_t cmd;
int inactive = 0;
grub_command_t *p, q;
cmd = (grub_command_t) grub_zalloc (sizeof (*cmd));
if (! cmd)
@ -42,9 +45,34 @@ grub_register_command_prio (const char *name,
cmd->flags = 0;
cmd->prio = prio;
for (p = &grub_command_list, q = *p; q; p = &(q->next), q = q->next)
{
int r;
grub_prio_list_insert (GRUB_AS_PRIO_LIST_P (&grub_command_list),
GRUB_AS_PRIO_LIST (cmd));
r = grub_strcmp (cmd->name, q->name);
if (r < 0)
break;
if (r > 0)
continue;
if (cmd->prio >= (q->prio & GRUB_COMMAND_PRIO_MASK))
{
q->prio &= ~GRUB_COMMAND_FLAG_ACTIVE;
break;
}
inactive = 1;
}
*p = cmd;
cmd->next = q;
if (q)
q->prev = &cmd->next;
cmd->prev = p;
if (! inactive)
cmd->prio |= GRUB_COMMAND_FLAG_ACTIVE;
return cmd;
}
@ -52,6 +80,8 @@ grub_register_command_prio (const char *name,
void
grub_unregister_command (grub_command_t cmd)
{
grub_prio_list_remove (GRUB_AS_PRIO_LIST (cmd));
if ((cmd->prio & GRUB_COMMAND_FLAG_ACTIVE) && (cmd->next))
cmd->next->prio |= GRUB_COMMAND_FLAG_ACTIVE;
grub_list_remove (GRUB_AS_LIST (cmd));
grub_free (cmd);
}

View file

@ -33,42 +33,6 @@ grub_named_list_find (grub_named_list_t head, const char *name)
return NULL;
}
void
grub_prio_list_insert (grub_prio_list_t *head, grub_prio_list_t nitem)
{
int inactive = 0;
grub_prio_list_t *p, q;
for (p = head, q = *p; q; p = &(q->next), q = q->next)
{
int r;
r = grub_strcmp (nitem->name, q->name);
if (r < 0)
break;
if (r > 0)
continue;
if (nitem->prio >= (q->prio & GRUB_PRIO_LIST_PRIO_MASK))
{
q->prio &= ~GRUB_PRIO_LIST_FLAG_ACTIVE;
break;
}
inactive = 1;
}
*p = nitem;
nitem->next = q;
if (q)
q->prev = &nitem->next;
nitem->prev = p;
if (! inactive)
nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
}
void
grub_list_push (grub_list_t *head, grub_list_t item)
{