Replace single-linked with double-linked lists. It results in more
compact and more efficient code. * grub-core/kern/list.c (grub_list_push): Moved from here ... * include/grub/list.h (grub_list_push): ... to here. Set prev. (grub_list_remove): Moved from here ... * include/grub/list.h (grub_list_remove): ... here. Use and set prev. (grub_prio_list_insert): Set prev. * include/grub/list.h (grub_list): Add prev. All users updated.
This commit is contained in:
parent
48b391e9ab
commit
87edb8940a
27 changed files with 111 additions and 75 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2012-01-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Replace single-linked with double-linked lists. It results in more
|
||||||
|
compact and more efficient code.
|
||||||
|
|
||||||
|
* grub-core/kern/list.c (grub_list_push): Moved from here ...
|
||||||
|
* include/grub/list.h (grub_list_push): ... to here. Set prev.
|
||||||
|
(grub_list_remove): Moved from here ...
|
||||||
|
* include/grub/list.h (grub_list_remove): ... here. Use and set prev.
|
||||||
|
(grub_prio_list_insert): Set prev.
|
||||||
|
* include/grub/list.h (grub_list): Add prev. All users updated.
|
||||||
|
|
||||||
2012-01-24 Vladimir Serbinenko <phcoder@gmail.com>
|
2012-01-24 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Handle newer autotools. Add some missing quotes while on it.
|
Handle newer autotools. Add some missing quotes while on it.
|
||||||
|
|
|
@ -340,7 +340,7 @@ grub_usb_register_attach_hook_class (struct grub_usb_attach_desc *desc)
|
||||||
void
|
void
|
||||||
grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc)
|
grub_usb_unregister_attach_hook_class (struct grub_usb_attach_desc *desc)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&attach_hooks), GRUB_AS_LIST (desc));
|
grub_list_remove (GRUB_AS_LIST (desc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ struct grub_term_autoload *grub_term_output_autoload = NULL;
|
||||||
struct abstract_terminal
|
struct abstract_terminal
|
||||||
{
|
{
|
||||||
struct abstract_terminal *next;
|
struct abstract_terminal *next;
|
||||||
|
struct abstract_terminal *prev;
|
||||||
const char *name;
|
const char *name;
|
||||||
grub_err_t (*init) (struct abstract_terminal *term);
|
grub_err_t (*init) (struct abstract_terminal *term);
|
||||||
grub_err_t (*fini) (struct abstract_terminal *term);
|
grub_err_t (*fini) (struct abstract_terminal *term);
|
||||||
|
@ -137,7 +138,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
||||||
if (term->init && term->init (term) != GRUB_ERR_NONE)
|
if (term->init && term->init (term) != GRUB_ERR_NONE)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
grub_list_remove (GRUB_AS_LIST (term));
|
||||||
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +157,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
||||||
if (!term->next && term == *enabled)
|
if (!term->next && term == *enabled)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
"can't remove the last terminal");
|
"can't remove the last terminal");
|
||||||
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
grub_list_remove (GRUB_AS_LIST (term));
|
||||||
if (term->fini)
|
if (term->fini)
|
||||||
term->fini (term);
|
term->fini (term);
|
||||||
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||||
|
@ -174,7 +175,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
||||||
if (term->init && term->init (term) != GRUB_ERR_NONE)
|
if (term->init && term->init (term) != GRUB_ERR_NONE)
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
grub_list_remove (GRUB_AS_LIST (term));
|
||||||
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
grub_list_push (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +193,7 @@ handle_command (int argc, char **args, struct abstract_terminal **enabled,
|
||||||
if (!term->next && term == *enabled)
|
if (!term->next && term == *enabled)
|
||||||
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
"can't remove the last terminal");
|
"can't remove the last terminal");
|
||||||
grub_list_remove (GRUB_AS_LIST_P (enabled), GRUB_AS_LIST (term));
|
grub_list_remove (GRUB_AS_LIST (term));
|
||||||
if (term->fini)
|
if (term->fini)
|
||||||
term->fini (term);
|
term->fini (term);
|
||||||
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
grub_list_push (GRUB_AS_LIST_P (disabled), GRUB_AS_LIST (term));
|
||||||
|
@ -208,6 +209,7 @@ grub_cmd_terminal_input (grub_command_t cmd __attribute__ ((unused)),
|
||||||
int argc, char **args)
|
int argc, char **args)
|
||||||
{
|
{
|
||||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, next);
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, next);
|
||||||
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, prev);
|
||||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, name);
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, name);
|
||||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init);
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, init);
|
||||||
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini);
|
(void) GRUB_FIELD_MATCH (grub_term_inputs, struct abstract_terminal *, fini);
|
||||||
|
@ -224,6 +226,7 @@ grub_cmd_terminal_output (grub_command_t cmd __attribute__ ((unused)),
|
||||||
int argc, char **args)
|
int argc, char **args)
|
||||||
{
|
{
|
||||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, next);
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, next);
|
||||||
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, prev);
|
||||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name);
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, name);
|
||||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init);
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, init);
|
||||||
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini);
|
(void) GRUB_FIELD_MATCH (grub_term_outputs, struct abstract_terminal *, fini);
|
||||||
|
|
|
@ -121,6 +121,7 @@ enum
|
||||||
struct grub_ahci_device
|
struct grub_ahci_device
|
||||||
{
|
{
|
||||||
struct grub_ahci_device *next;
|
struct grub_ahci_device *next;
|
||||||
|
struct grub_ahci_device **prev;
|
||||||
volatile struct grub_ahci_hba *hba;
|
volatile struct grub_ahci_hba *hba;
|
||||||
int port;
|
int port;
|
||||||
int num;
|
int num;
|
||||||
|
|
|
@ -46,6 +46,7 @@ static const char *(*grub_gettext_original) (const char *s);
|
||||||
struct grub_gettext_msg
|
struct grub_gettext_msg
|
||||||
{
|
{
|
||||||
struct grub_gettext_msg *next;
|
struct grub_gettext_msg *next;
|
||||||
|
struct grub_gettext_msg *prev;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
const char *translated;
|
const char *translated;
|
||||||
|
|
|
@ -52,7 +52,6 @@ grub_register_command_prio (const char *name,
|
||||||
void
|
void
|
||||||
grub_unregister_command (grub_command_t cmd)
|
grub_unregister_command (grub_command_t cmd)
|
||||||
{
|
{
|
||||||
grub_prio_list_remove (GRUB_AS_PRIO_LIST_P (&grub_command_list),
|
grub_prio_list_remove (GRUB_AS_PRIO_LIST (cmd));
|
||||||
GRUB_AS_PRIO_LIST (cmd));
|
|
||||||
grub_free (cmd);
|
grub_free (cmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -635,6 +635,7 @@ devmapper_fail:
|
||||||
struct linux_partition_cache
|
struct linux_partition_cache
|
||||||
{
|
{
|
||||||
struct linux_partition_cache *next;
|
struct linux_partition_cache *next;
|
||||||
|
struct linux_partition_cache **prev;
|
||||||
char *dev;
|
char *dev;
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
int partno;
|
int partno;
|
||||||
|
|
|
@ -21,26 +21,6 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/mm.h>
|
#include <grub/mm.h>
|
||||||
|
|
||||||
void
|
|
||||||
grub_list_push (grub_list_t *head, grub_list_t item)
|
|
||||||
{
|
|
||||||
item->next = *head;
|
|
||||||
*head = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
grub_list_remove (grub_list_t *head, grub_list_t item)
|
|
||||||
{
|
|
||||||
grub_list_t *p, q;
|
|
||||||
|
|
||||||
for (p = head, q = *p; q; p = &(q->next), q = q->next)
|
|
||||||
if (q == item)
|
|
||||||
{
|
|
||||||
*p = q->next;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
grub_named_list_find (grub_named_list_t head, const char *name)
|
grub_named_list_find (grub_named_list_t head, const char *name)
|
||||||
{
|
{
|
||||||
|
@ -81,6 +61,9 @@ grub_prio_list_insert (grub_prio_list_t *head, grub_prio_list_t nitem)
|
||||||
|
|
||||||
*p = nitem;
|
*p = nitem;
|
||||||
nitem->next = q;
|
nitem->next = q;
|
||||||
|
if (q)
|
||||||
|
q->prev = &nitem->next;
|
||||||
|
nitem->prev = p;
|
||||||
|
|
||||||
if (! inactive)
|
if (! inactive)
|
||||||
nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
|
nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
|
||||||
|
|
|
@ -58,6 +58,7 @@ static struct tbl_alias table_aliases[] =
|
||||||
struct grub_xnu_devprop_device_descriptor
|
struct grub_xnu_devprop_device_descriptor
|
||||||
{
|
{
|
||||||
struct grub_xnu_devprop_device_descriptor *next;
|
struct grub_xnu_devprop_device_descriptor *next;
|
||||||
|
struct grub_xnu_devprop_device_descriptor **prev;
|
||||||
struct property_descriptor *properties;
|
struct property_descriptor *properties;
|
||||||
struct grub_efi_device_path *path;
|
struct grub_efi_device_path *path;
|
||||||
int pathlen;
|
int pathlen;
|
||||||
|
@ -212,6 +213,7 @@ guessfsb (void)
|
||||||
struct property_descriptor
|
struct property_descriptor
|
||||||
{
|
{
|
||||||
struct property_descriptor *next;
|
struct property_descriptor *next;
|
||||||
|
struct property_descriptor **prev;
|
||||||
grub_uint8_t *name;
|
grub_uint8_t *name;
|
||||||
grub_uint16_t *name16;
|
grub_uint16_t *name16;
|
||||||
int name16len;
|
int name16len;
|
||||||
|
@ -234,7 +236,7 @@ grub_xnu_devprop_remove_property (struct grub_xnu_devprop_device_descriptor *dev
|
||||||
grub_free (prop->name16);
|
grub_free (prop->name16);
|
||||||
grub_free (prop->data);
|
grub_free (prop->data);
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&dev->properties), GRUB_AS_LIST (prop));
|
grub_list_remove (GRUB_AS_LIST (prop));
|
||||||
|
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +247,7 @@ grub_xnu_devprop_remove_device (struct grub_xnu_devprop_device_descriptor *dev)
|
||||||
void *t;
|
void *t;
|
||||||
struct property_descriptor *prop;
|
struct property_descriptor *prop;
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&devices), GRUB_AS_LIST (dev));
|
grub_list_remove (GRUB_AS_LIST (dev));
|
||||||
|
|
||||||
for (prop = dev->properties; prop; )
|
for (prop = dev->properties; prop; )
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@ char *grub_net_default_server;
|
||||||
struct grub_net_route
|
struct grub_net_route
|
||||||
{
|
{
|
||||||
struct grub_net_route *next;
|
struct grub_net_route *next;
|
||||||
|
struct grub_net_route **prev;
|
||||||
grub_net_network_level_netaddress_t target;
|
grub_net_network_level_netaddress_t target;
|
||||||
char *name;
|
char *name;
|
||||||
struct grub_net_network_level_protocol *prot;
|
struct grub_net_network_level_protocol *prot;
|
||||||
|
@ -206,8 +207,7 @@ grub_net_card_unregister (struct grub_net_card *card)
|
||||||
card->driver->close (card);
|
card->driver->close (card);
|
||||||
card->opened = 0;
|
card->opened = 0;
|
||||||
}
|
}
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_net_cards),
|
grub_list_remove (GRUB_AS_LIST (card));
|
||||||
GRUB_AS_LIST (card));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct grub_net_slaac_mac_list *
|
static struct grub_net_slaac_mac_list *
|
||||||
|
@ -366,8 +366,7 @@ grub_net_route_register (struct grub_net_route *route)
|
||||||
static inline void
|
static inline void
|
||||||
grub_net_route_unregister (struct grub_net_route *route)
|
grub_net_route_unregister (struct grub_net_route *route)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_net_routes),
|
grub_list_remove (GRUB_AS_LIST (route));
|
||||||
GRUB_AS_LIST (route));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next)
|
#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
struct unacked
|
struct unacked
|
||||||
{
|
{
|
||||||
struct unacked *next;
|
struct unacked *next;
|
||||||
|
struct unacked **prev;
|
||||||
struct grub_net_buff *nb;
|
struct grub_net_buff *nb;
|
||||||
grub_uint64_t last_try;
|
grub_uint64_t last_try;
|
||||||
int try_count;
|
int try_count;
|
||||||
|
@ -49,6 +50,7 @@ enum
|
||||||
struct grub_net_tcp_socket
|
struct grub_net_tcp_socket
|
||||||
{
|
{
|
||||||
struct grub_net_tcp_socket *next;
|
struct grub_net_tcp_socket *next;
|
||||||
|
struct grub_net_tcp_socket **prev;
|
||||||
|
|
||||||
int established;
|
int established;
|
||||||
int i_closed;
|
int i_closed;
|
||||||
|
@ -80,6 +82,7 @@ struct grub_net_tcp_socket
|
||||||
struct grub_net_tcp_listen
|
struct grub_net_tcp_listen
|
||||||
{
|
{
|
||||||
struct grub_net_tcp_listen *next;
|
struct grub_net_tcp_listen *next;
|
||||||
|
struct grub_net_tcp_listen **prev;
|
||||||
|
|
||||||
grub_uint16_t port;
|
grub_uint16_t port;
|
||||||
const struct grub_net_network_level_interface *inf;
|
const struct grub_net_network_level_interface *inf;
|
||||||
|
@ -149,8 +152,7 @@ grub_net_tcp_listen (grub_uint16_t port,
|
||||||
void
|
void
|
||||||
grub_net_tcp_stop_listen (grub_net_tcp_listen_t listen)
|
grub_net_tcp_stop_listen (grub_net_tcp_listen_t listen)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&tcp_listens),
|
grub_list_remove (GRUB_AS_LIST (listen));
|
||||||
GRUB_AS_LIST (listen));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -640,8 +642,7 @@ grub_net_tcp_open (char *server,
|
||||||
GRUB_NET_IP_TCP);
|
GRUB_NET_IP_TCP);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&tcp_sockets),
|
grub_list_remove (GRUB_AS_LIST (socket));
|
||||||
GRUB_AS_LIST (socket));
|
|
||||||
grub_free (socket);
|
grub_free (socket);
|
||||||
grub_netbuff_free (nb);
|
grub_netbuff_free (nb);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -654,8 +655,7 @@ grub_net_tcp_open (char *server,
|
||||||
}
|
}
|
||||||
if (!socket->established)
|
if (!socket->established)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&tcp_sockets),
|
grub_list_remove (GRUB_AS_LIST (socket));
|
||||||
GRUB_AS_LIST (socket));
|
|
||||||
if (socket->they_reseted)
|
if (socket->they_reseted)
|
||||||
grub_error (GRUB_ERR_NET_PORT_CLOSED, "port closed");
|
grub_error (GRUB_ERR_NET_PORT_CLOSED, "port closed");
|
||||||
else
|
else
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
struct grub_net_udp_socket
|
struct grub_net_udp_socket
|
||||||
{
|
{
|
||||||
struct grub_net_udp_socket *next;
|
struct grub_net_udp_socket *next;
|
||||||
|
struct grub_net_udp_socket **prev;
|
||||||
|
|
||||||
enum { GRUB_NET_SOCKET_START,
|
enum { GRUB_NET_SOCKET_START,
|
||||||
GRUB_NET_SOCKET_ESTABLISHED,
|
GRUB_NET_SOCKET_ESTABLISHED,
|
||||||
|
@ -53,8 +54,7 @@ udp_socket_register (grub_net_udp_socket_t sock)
|
||||||
void
|
void
|
||||||
grub_net_udp_close (grub_net_udp_socket_t sock)
|
grub_net_udp_close (grub_net_udp_socket_t sock)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&udp_sockets),
|
grub_list_remove (GRUB_AS_LIST (sock));
|
||||||
GRUB_AS_LIST (sock));
|
|
||||||
grub_free (sock);
|
grub_free (sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
struct grub_auth_user
|
struct grub_auth_user
|
||||||
{
|
{
|
||||||
struct grub_auth_user *next;
|
struct grub_auth_user *next;
|
||||||
|
struct grub_auth_user **prev;
|
||||||
char *name;
|
char *name;
|
||||||
grub_auth_callback_t callback;
|
grub_auth_callback_t callback;
|
||||||
void *arg;
|
void *arg;
|
||||||
|
@ -73,7 +74,7 @@ grub_auth_unregister_authentication (const char *user)
|
||||||
if (!cur->authenticated)
|
if (!cur->authenticated)
|
||||||
{
|
{
|
||||||
grub_free (cur->name);
|
grub_free (cur->name);
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&users), GRUB_AS_LIST (cur));
|
grub_list_remove (GRUB_AS_LIST (cur));
|
||||||
grub_free (cur);
|
grub_free (cur);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -121,7 +122,7 @@ grub_auth_deauthenticate (const char *user)
|
||||||
if (!cur->callback)
|
if (!cur->callback)
|
||||||
{
|
{
|
||||||
grub_free (cur->name);
|
grub_free (cur->name);
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&users), GRUB_AS_LIST (cur));
|
grub_list_remove (GRUB_AS_LIST (cur));
|
||||||
grub_free (cur);
|
grub_free (cur);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -350,7 +350,7 @@ grub_serial_unregister (struct grub_serial_port *port)
|
||||||
if (port->term_out)
|
if (port->term_out)
|
||||||
grub_term_unregister_output (port->term_out);
|
grub_term_unregister_output (port->term_out);
|
||||||
|
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_serial_ports), GRUB_AS_LIST (port));
|
grub_list_remove (GRUB_AS_LIST (port));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct grub_test_failure
|
||||||
{
|
{
|
||||||
/* The next failure. */
|
/* The next failure. */
|
||||||
struct grub_test_failure *next;
|
struct grub_test_failure *next;
|
||||||
|
struct grub_test_failure **prev;
|
||||||
|
|
||||||
/* The test source file name. */
|
/* The test source file name. */
|
||||||
char *file;
|
char *file;
|
||||||
|
@ -124,7 +125,7 @@ grub_test_unregister (const char *name)
|
||||||
|
|
||||||
if (test)
|
if (test)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_test_list), GRUB_AS_LIST (test));
|
grub_list_remove (GRUB_AS_LIST (test));
|
||||||
|
|
||||||
if (test->name)
|
if (test->name)
|
||||||
grub_free (test->name);
|
grub_free (test->name);
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct grub_command
|
||||||
{
|
{
|
||||||
/* The next element. */
|
/* The next element. */
|
||||||
struct grub_command *next;
|
struct grub_command *next;
|
||||||
|
struct grub_command **prev;
|
||||||
|
|
||||||
/* The name. */
|
/* The name. */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
|
@ -59,6 +59,7 @@ typedef gcry_err_code_t
|
||||||
struct grub_cryptodisk
|
struct grub_cryptodisk
|
||||||
{
|
{
|
||||||
struct grub_cryptodisk *next;
|
struct grub_cryptodisk *next;
|
||||||
|
struct grub_cryptodisk **prev;
|
||||||
|
|
||||||
char *source;
|
char *source;
|
||||||
grub_disk_addr_t offset;
|
grub_disk_addr_t offset;
|
||||||
|
@ -96,6 +97,7 @@ typedef struct grub_cryptodisk *grub_cryptodisk_t;
|
||||||
struct grub_cryptodisk_dev
|
struct grub_cryptodisk_dev
|
||||||
{
|
{
|
||||||
struct grub_cryptodisk_dev *next;
|
struct grub_cryptodisk_dev *next;
|
||||||
|
struct grub_cryptodisk_dev **prev;
|
||||||
|
|
||||||
grub_cryptodisk_t (*scan) (grub_disk_t disk, const char *check_uuid,
|
grub_cryptodisk_t (*scan) (grub_disk_t disk, const char *check_uuid,
|
||||||
int boot_only);
|
int boot_only);
|
||||||
|
@ -116,7 +118,7 @@ grub_cryptodisk_dev_register (grub_cryptodisk_dev_t cr)
|
||||||
static inline void
|
static inline void
|
||||||
grub_cryptodisk_dev_unregister (grub_cryptodisk_dev_t cr)
|
grub_cryptodisk_dev_unregister (grub_cryptodisk_dev_t cr)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_cryptodisk_list), GRUB_AS_LIST (cr));
|
grub_list_remove (GRUB_AS_LIST (cr));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOR_CRYPTODISK_DEVS(var) FOR_LIST_ELEMENTS((var), (grub_cryptodisk_list))
|
#define FOR_CRYPTODISK_DEVS(var) FOR_LIST_ELEMENTS((var), (grub_cryptodisk_list))
|
||||||
|
|
|
@ -46,6 +46,7 @@ struct grub_fs
|
||||||
{
|
{
|
||||||
/* The next filesystem. */
|
/* The next filesystem. */
|
||||||
struct grub_fs *next;
|
struct grub_fs *next;
|
||||||
|
struct grub_fs **prev;
|
||||||
|
|
||||||
/* My name. */
|
/* My name. */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -111,7 +112,7 @@ grub_fs_register (grub_fs_t fs)
|
||||||
static inline void
|
static inline void
|
||||||
grub_fs_unregister (grub_fs_t fs)
|
grub_fs_unregister (grub_fs_t fs)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
|
grub_list_remove (GRUB_AS_LIST (fs));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
|
#define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
|
||||||
|
|
|
@ -27,11 +27,27 @@
|
||||||
struct grub_list
|
struct grub_list
|
||||||
{
|
{
|
||||||
struct grub_list *next;
|
struct grub_list *next;
|
||||||
|
struct grub_list **prev;
|
||||||
};
|
};
|
||||||
typedef struct grub_list *grub_list_t;
|
typedef struct grub_list *grub_list_t;
|
||||||
|
|
||||||
void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
|
static inline void
|
||||||
void EXPORT_FUNC(grub_list_remove) (grub_list_t *head, grub_list_t item);
|
grub_list_push (grub_list_t *head, grub_list_t item)
|
||||||
|
{
|
||||||
|
item->prev = head;
|
||||||
|
if (*head)
|
||||||
|
(*head)->prev = &item->next;
|
||||||
|
item->next = *head;
|
||||||
|
*head = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
grub_list_remove (grub_list_t item)
|
||||||
|
{
|
||||||
|
*item->prev = item->next;
|
||||||
|
if (item->next)
|
||||||
|
item->next->prev = item->prev;
|
||||||
|
}
|
||||||
|
|
||||||
#define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next)
|
#define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next)
|
||||||
|
|
||||||
|
@ -53,16 +69,17 @@ grub_bad_type_cast_real (int line, const char *file)
|
||||||
((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
|
((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
|
||||||
|
|
||||||
#define GRUB_AS_LIST(ptr) \
|
#define GRUB_AS_LIST(ptr) \
|
||||||
(GRUB_FIELD_MATCH (ptr, grub_list_t, next) ? \
|
(GRUB_FIELD_MATCH (ptr, grub_list_t, next) && GRUB_FIELD_MATCH (ptr, grub_list_t, prev) ? \
|
||||||
(grub_list_t) ptr : (grub_list_t) grub_bad_type_cast ())
|
(grub_list_t) ptr : (grub_list_t) grub_bad_type_cast ())
|
||||||
|
|
||||||
#define GRUB_AS_LIST_P(pptr) \
|
#define GRUB_AS_LIST_P(pptr) \
|
||||||
(GRUB_FIELD_MATCH (*pptr, grub_list_t, next) ? \
|
(GRUB_FIELD_MATCH (*pptr, grub_list_t, next) && GRUB_FIELD_MATCH (*pptr, grub_list_t, prev) ? \
|
||||||
(grub_list_t *) (void *) pptr : (grub_list_t *) grub_bad_type_cast ())
|
(grub_list_t *) (void *) pptr : (grub_list_t *) grub_bad_type_cast ())
|
||||||
|
|
||||||
struct grub_named_list
|
struct grub_named_list
|
||||||
{
|
{
|
||||||
struct grub_named_list *next;
|
struct grub_named_list *next;
|
||||||
|
struct grub_named_list **prev;
|
||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
typedef struct grub_named_list *grub_named_list_t;
|
typedef struct grub_named_list *grub_named_list_t;
|
||||||
|
@ -71,13 +88,15 @@ void * EXPORT_FUNC(grub_named_list_find) (grub_named_list_t head,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
|
||||||
#define GRUB_AS_NAMED_LIST(ptr) \
|
#define GRUB_AS_NAMED_LIST(ptr) \
|
||||||
((GRUB_FIELD_MATCH (ptr, grub_named_list_t, next) && \
|
((GRUB_FIELD_MATCH (ptr, grub_named_list_t, next) \
|
||||||
GRUB_FIELD_MATCH (ptr, grub_named_list_t, name))? \
|
&& GRUB_FIELD_MATCH (ptr, grub_named_list_t, prev) \
|
||||||
|
&& GRUB_FIELD_MATCH (ptr, grub_named_list_t, name))? \
|
||||||
(grub_named_list_t) ptr : (grub_named_list_t) grub_bad_type_cast ())
|
(grub_named_list_t) ptr : (grub_named_list_t) grub_bad_type_cast ())
|
||||||
|
|
||||||
#define GRUB_AS_NAMED_LIST_P(pptr) \
|
#define GRUB_AS_NAMED_LIST_P(pptr) \
|
||||||
((GRUB_FIELD_MATCH (*pptr, grub_named_list_t, next) && \
|
((GRUB_FIELD_MATCH (*pptr, grub_named_list_t, next) \
|
||||||
GRUB_FIELD_MATCH (*pptr, grub_named_list_t, name))? \
|
&& GRUB_FIELD_MATCH (*pptr, grub_named_list_t, prev) \
|
||||||
|
&& GRUB_FIELD_MATCH (*pptr, grub_named_list_t, name))? \
|
||||||
(grub_named_list_t *) (void *) pptr : (grub_named_list_t *) grub_bad_type_cast ())
|
(grub_named_list_t *) (void *) pptr : (grub_named_list_t *) grub_bad_type_cast ())
|
||||||
|
|
||||||
#define GRUB_PRIO_LIST_PRIO_MASK 0xff
|
#define GRUB_PRIO_LIST_PRIO_MASK 0xff
|
||||||
|
@ -86,6 +105,7 @@ void * EXPORT_FUNC(grub_named_list_find) (grub_named_list_t head,
|
||||||
struct grub_prio_list
|
struct grub_prio_list
|
||||||
{
|
{
|
||||||
struct grub_prio_list *next;
|
struct grub_prio_list *next;
|
||||||
|
struct grub_prio_list **prev;
|
||||||
char *name;
|
char *name;
|
||||||
int prio;
|
int prio;
|
||||||
};
|
};
|
||||||
|
@ -95,24 +115,26 @@ void EXPORT_FUNC(grub_prio_list_insert) (grub_prio_list_t *head,
|
||||||
grub_prio_list_t item);
|
grub_prio_list_t item);
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
grub_prio_list_remove (grub_prio_list_t *head, grub_prio_list_t item)
|
grub_prio_list_remove (grub_prio_list_t item)
|
||||||
{
|
{
|
||||||
if ((item->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && (item->next))
|
if ((item->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) && (item->next))
|
||||||
item->next->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
|
item->next->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
|
||||||
grub_list_remove (GRUB_AS_LIST_P (head), GRUB_AS_LIST (item));
|
grub_list_remove (GRUB_AS_LIST (item));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define GRUB_AS_PRIO_LIST(ptr) \
|
#define GRUB_AS_PRIO_LIST(ptr) \
|
||||||
((GRUB_FIELD_MATCH (ptr, grub_prio_list_t, next) && \
|
((GRUB_FIELD_MATCH (ptr, grub_prio_list_t, next) \
|
||||||
GRUB_FIELD_MATCH (ptr, grub_prio_list_t, name) && \
|
&& GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prev) \
|
||||||
GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prio))? \
|
&& GRUB_FIELD_MATCH (ptr, grub_prio_list_t, name) \
|
||||||
|
&& GRUB_FIELD_MATCH (ptr, grub_prio_list_t, prio))? \
|
||||||
(grub_prio_list_t) ptr \
|
(grub_prio_list_t) ptr \
|
||||||
: (grub_prio_list_t) grub_bad_type_cast ())
|
: (grub_prio_list_t) grub_bad_type_cast ())
|
||||||
|
|
||||||
#define GRUB_AS_PRIO_LIST_P(pptr) \
|
#define GRUB_AS_PRIO_LIST_P(pptr) \
|
||||||
((GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, next) && \
|
((GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, next) \
|
||||||
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, name) && \
|
&& GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prev) \
|
||||||
GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio)) ? \
|
&& GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, name) \
|
||||||
|
&& GRUB_FIELD_MATCH (*pptr, grub_prio_list_t, prio)) ? \
|
||||||
(grub_prio_list_t *) (void *) pptr \
|
(grub_prio_list_t *) (void *) pptr \
|
||||||
: (grub_prio_list_t *) grub_bad_type_cast ())
|
: (grub_prio_list_t *) grub_bad_type_cast ())
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ struct grub_net_card;
|
||||||
struct grub_net_card_driver
|
struct grub_net_card_driver
|
||||||
{
|
{
|
||||||
struct grub_net_card_driver *next;
|
struct grub_net_card_driver *next;
|
||||||
|
struct grub_net_card_driver **prev;
|
||||||
const char *name;
|
const char *name;
|
||||||
grub_err_t (*open) (const struct grub_net_card *dev);
|
grub_err_t (*open) (const struct grub_net_card *dev);
|
||||||
void (*close) (const struct grub_net_card *dev);
|
void (*close) (const struct grub_net_card *dev);
|
||||||
|
@ -101,6 +102,7 @@ typedef struct grub_net_packets
|
||||||
struct grub_net_slaac_mac_list
|
struct grub_net_slaac_mac_list
|
||||||
{
|
{
|
||||||
struct grub_net_slaac_mac_list *next;
|
struct grub_net_slaac_mac_list *next;
|
||||||
|
struct grub_net_slaac_mac_list **prev;
|
||||||
grub_net_link_level_address_t address;
|
grub_net_link_level_address_t address;
|
||||||
int slaac_counter;
|
int slaac_counter;
|
||||||
char *name;
|
char *name;
|
||||||
|
@ -111,6 +113,7 @@ struct grub_net_link_layer_entry;
|
||||||
struct grub_net_card
|
struct grub_net_card
|
||||||
{
|
{
|
||||||
struct grub_net_card *next;
|
struct grub_net_card *next;
|
||||||
|
struct grub_net_card **prev;
|
||||||
const char *name;
|
const char *name;
|
||||||
struct grub_net_card_driver *driver;
|
struct grub_net_card_driver *driver;
|
||||||
grub_net_link_level_address_t default_address;
|
grub_net_link_level_address_t default_address;
|
||||||
|
@ -220,6 +223,7 @@ typedef struct grub_net_socket *grub_net_socket_t;
|
||||||
struct grub_net_app_protocol
|
struct grub_net_app_protocol
|
||||||
{
|
{
|
||||||
struct grub_net_app_protocol *next;
|
struct grub_net_app_protocol *next;
|
||||||
|
struct grub_net_app_protocol **prev;
|
||||||
const char *name;
|
const char *name;
|
||||||
grub_err_t (*dir) (grub_device_t device, const char *path,
|
grub_err_t (*dir) (grub_device_t device, const char *path,
|
||||||
int (*hook) (const char *filename,
|
int (*hook) (const char *filename,
|
||||||
|
@ -317,8 +321,7 @@ grub_net_app_level_register (grub_net_app_level_t proto)
|
||||||
static inline void
|
static inline void
|
||||||
grub_net_app_level_unregister (grub_net_app_level_t proto)
|
grub_net_app_level_unregister (grub_net_app_level_t proto)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_net_app_level_list),
|
grub_list_remove (GRUB_AS_LIST (proto));
|
||||||
GRUB_AS_LIST (proto));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOR_NET_APP_LEVEL(var) FOR_LIST_ELEMENTS((var), \
|
#define FOR_NET_APP_LEVEL(var) FOR_LIST_ELEMENTS((var), \
|
||||||
|
|
|
@ -38,6 +38,7 @@ struct grub_partition_map
|
||||||
{
|
{
|
||||||
/* The next partition map type. */
|
/* The next partition map type. */
|
||||||
struct grub_partition_map *next;
|
struct grub_partition_map *next;
|
||||||
|
struct grub_partition_map **prev;
|
||||||
|
|
||||||
/* The name of the partition map type. */
|
/* The name of the partition map type. */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -106,8 +107,7 @@ grub_partition_map_register (grub_partition_map_t partmap)
|
||||||
static inline void
|
static inline void
|
||||||
grub_partition_map_unregister (grub_partition_map_t partmap)
|
grub_partition_map_unregister (grub_partition_map_t partmap)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_partition_map_list),
|
grub_list_remove (GRUB_AS_LIST (partmap));
|
||||||
GRUB_AS_LIST (partmap));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
|
#define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
|
||||||
|
|
|
@ -63,6 +63,7 @@ struct grub_serial_config
|
||||||
struct grub_serial_port
|
struct grub_serial_port
|
||||||
{
|
{
|
||||||
struct grub_serial_port *next;
|
struct grub_serial_port *next;
|
||||||
|
struct grub_serial_port **prev;
|
||||||
char *name;
|
char *name;
|
||||||
struct grub_serial_driver *driver;
|
struct grub_serial_driver *driver;
|
||||||
struct grub_serial_config config;
|
struct grub_serial_config config;
|
||||||
|
|
|
@ -147,6 +147,7 @@ struct grub_term_input
|
||||||
{
|
{
|
||||||
/* The next terminal. */
|
/* The next terminal. */
|
||||||
struct grub_term_input *next;
|
struct grub_term_input *next;
|
||||||
|
struct grub_term_input **prev;
|
||||||
|
|
||||||
/* The terminal name. */
|
/* The terminal name. */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -171,6 +172,7 @@ struct grub_term_output
|
||||||
{
|
{
|
||||||
/* The next terminal. */
|
/* The next terminal. */
|
||||||
struct grub_term_output *next;
|
struct grub_term_output *next;
|
||||||
|
struct grub_term_output **prev;
|
||||||
|
|
||||||
/* The terminal name. */
|
/* The terminal name. */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -300,17 +302,15 @@ grub_term_register_output_active (const char *name __attribute__ ((unused)),
|
||||||
static inline void
|
static inline void
|
||||||
grub_term_unregister_input (grub_term_input_t term)
|
grub_term_unregister_input (grub_term_input_t term)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs), GRUB_AS_LIST (term));
|
grub_list_remove (GRUB_AS_LIST (term));
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_term_inputs_disabled),
|
grub_list_remove (GRUB_AS_LIST (term));
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
grub_term_unregister_output (grub_term_output_t term)
|
grub_term_unregister_output (grub_term_output_t term)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_term_outputs), GRUB_AS_LIST (term));
|
grub_list_remove (GRUB_AS_LIST (term));
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&(grub_term_outputs_disabled)),
|
grub_list_remove (GRUB_AS_LIST (term));
|
||||||
GRUB_AS_LIST (term));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs))
|
#define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs))
|
||||||
|
|
|
@ -29,6 +29,7 @@ struct grub_test
|
||||||
{
|
{
|
||||||
/* The next test. */
|
/* The next test. */
|
||||||
struct grub_test *next;
|
struct grub_test *next;
|
||||||
|
struct grub_test **prev;
|
||||||
|
|
||||||
/* The test name. */
|
/* The test name. */
|
||||||
char *name;
|
char *name;
|
||||||
|
|
|
@ -264,6 +264,7 @@ typedef int (*grub_usb_attach_hook_class) (grub_usb_device_t usbdev,
|
||||||
struct grub_usb_attach_desc
|
struct grub_usb_attach_desc
|
||||||
{
|
{
|
||||||
struct grub_usb_attach_desc *next;
|
struct grub_usb_attach_desc *next;
|
||||||
|
struct grub_usb_attach_desc **prev;
|
||||||
int class;
|
int class;
|
||||||
grub_usb_attach_hook_class hook;
|
grub_usb_attach_hook_class hook;
|
||||||
};
|
};
|
||||||
|
|
|
@ -298,6 +298,7 @@ struct grub_video_adapter
|
||||||
{
|
{
|
||||||
/* The next video adapter. */
|
/* The next video adapter. */
|
||||||
struct grub_video_adapter *next;
|
struct grub_video_adapter *next;
|
||||||
|
struct grub_video_adapter **prev;
|
||||||
|
|
||||||
/* The video adapter name. */
|
/* The video adapter name. */
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -398,8 +399,7 @@ grub_video_register (grub_video_adapter_t adapter)
|
||||||
static inline void
|
static inline void
|
||||||
grub_video_unregister (grub_video_adapter_t adapter)
|
grub_video_unregister (grub_video_adapter_t adapter)
|
||||||
{
|
{
|
||||||
grub_list_remove (GRUB_AS_LIST_P (&grub_video_adapter_list),
|
grub_list_remove (GRUB_AS_LIST (adapter));
|
||||||
GRUB_AS_LIST (adapter));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FOR_VIDEO_ADAPTERS(var) FOR_LIST_ELEMENTS((var), (grub_video_adapter_list))
|
#define FOR_VIDEO_ADAPTERS(var) FOR_LIST_ELEMENTS((var), (grub_video_adapter_list))
|
||||||
|
|
|
@ -369,6 +369,7 @@ get_xvd_disk_name (char *name, int unit)
|
||||||
static struct seen_device
|
static struct seen_device
|
||||||
{
|
{
|
||||||
struct seen_device *next;
|
struct seen_device *next;
|
||||||
|
struct seen_device **prev;
|
||||||
const char *name;
|
const char *name;
|
||||||
} *seen;
|
} *seen;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue