list.h File Reference

Linked lists. More...

#include <stddef.h>
#include <assert.h>

Go to the source code of this file.

Data Structures

struct  list_head

Defines

#define LIST_HEAD_INIT(name)   { &(name), &(name) }
#define LIST_HEAD(name)   struct list_head name = LIST_HEAD_INIT ( name )
#define INIT_LIST_HEAD(ptr)
#define list_add(new, head)
#define list_add_tail(new, head)
#define list_del(entry)
#define list_entry(ptr, type, member)   container_of ( ptr, type, member )
 Get the containing struct for this entry.
#define list_for_each(pos, head)   for ( pos = (head)->next; pos != (head); pos = pos->next )
 Iterate over a list.
#define list_for_each_entry(pos, head, member)
 Iterate over entries in a list.
#define list_for_each_entry_safe(pos, tmp, head, member)
 Iterate over entries in a list, safe against deletion of entries.

Functions

 FILE_LICENCE (GPL2_ONLY)
static void __list_add (struct list_head *new, struct list_head *prev, struct list_head *next)
static void list_add (struct list_head *new, struct list_head *head)
 Add a new entry to the head of a list.
static void list_add_tail (struct list_head *new, struct list_head *head)
 Add a new entry to the tail of a list.
static void __list_del (struct list_head *prev, struct list_head *next)
static void list_del (struct list_head *entry)
 Delete an entry from a list.
static int list_empty (const struct list_head *head)
 Test whether a list is empty.


Detailed Description

Linked lists.

This linked list handling code is based on the Linux kernel's list.h.

Definition in file list.h.


Define Documentation

#define LIST_HEAD_INIT ( name   )     { &(name), &(name) }

Definition at line 32 of file list.h.

#define LIST_HEAD ( name   )     struct list_head name = LIST_HEAD_INIT ( name )

Definition at line 34 of file list.h.

#define INIT_LIST_HEAD ( ptr   ) 

#define list_add ( new,
head   ) 

#define list_add_tail ( new,
head   ) 

#define list_del ( entry   ) 

#define list_entry ( ptr,
type,
member   )     container_of ( ptr, type, member )

Get the containing struct for this entry.

Parameters:
ptr The struct list_head pointer
type The type of the struct this is embedded in
member The name of the list_struct within the struct

Definition at line 141 of file list.h.

Referenced by ath5k_handle_rx(), ath5k_rx_start(), ath5k_tx(), and sis190_default_phy().

#define list_for_each ( pos,
head   )     for ( pos = (head)->next; pos != (head); pos = pos->next )

Iterate over a list.

Parameters:
pos The &struct list_head to use as a loop counter
head The head for your list

Definition at line 150 of file list.h.

#define list_for_each_entry ( pos,
head,
member   ) 

#define list_for_each_entry_safe ( pos,
tmp,
head,
member   ) 

Value:

for ( pos = list_entry ( (head)->next, typeof ( *pos ), member ),     \
              tmp = list_entry ( pos->member.next, typeof ( *tmp ), member ); \
              &pos->member != (head);                                         \
              pos = tmp,                                                      \
              tmp = list_entry ( tmp->member.next, typeof ( *tmp ), member ) )
Iterate over entries in a list, safe against deletion of entries.

Parameters:
pos The type * to use as a loop counter
tmp Another type * to use for temporary storage
head The head for your list
member The name of the list_struct within the struct

Definition at line 173 of file list.h.

Referenced by ath5k_tx_processq(), ath5k_txq_drainq(), eisabus_remove(), generic_settings_clear(), ib_destroy_mi(), imgfree_exec(), ipv4_create_routes(), isabus_remove(), isapnpbus_remove(), mcabus_remove(), net80211_free_wlanlist(), pcibus_remove(), posix_file_free(), remove_devices(), retry_step(), sis190_free_phy(), t509bus_remove(), tcp_close(), tcp_process_queue(), and wpa_stop().


Function Documentation

FILE_LICENCE ( GPL2_ONLY   ) 

static void __list_add ( struct list_head new,
struct list_head prev,
struct list_head next 
) [inline, static]

Definition at line 47 of file list.h.

References list_head::next, and list_head::prev.

Referenced by list_add(), and list_add_tail().

00049                                                          {
00050         next->prev = new;
00051         new->next = next;
00052         new->prev = prev;
00053         prev->next = new;
00054 }

static void list_add ( struct list_head new,
struct list_head head 
) [inline, static]

Add a new entry to the head of a list.

Parameters:
new New entry to be added
head List head to add it after
Insert a new entry after the specified head. This is good for implementing stacks.

Definition at line 65 of file list.h.

References __list_add(), and list_head::next.

00065                                                                               {
00066         __list_add ( new, head, head->next );
00067 }

static void list_add_tail ( struct list_head new,
struct list_head head 
) [inline, static]

Add a new entry to the tail of a list.

Parameters:
new New entry to be added
head List head to add it before
Insert a new entry before the specified head. This is useful for implementing queues.

Definition at line 83 of file list.h.

References __list_add(), and list_head::prev.

00084                                                             {
00085         __list_add ( new, head->prev, head );
00086 }

static void __list_del ( struct list_head prev,
struct list_head next 
) [inline, static]

Definition at line 100 of file list.h.

References list_head::next, and list_head::prev.

Referenced by list_del().

00101                                                           {
00102         next->prev = prev;
00103         prev->next = next;
00104 }

static void list_del ( struct list_head entry  )  [inline, static]

Delete an entry from a list.

Parameters:
entry Element to delete from the list
Note that list_empty() on entry does not return true after this; the entry is in an undefined state.

Definition at line 114 of file list.h.

References __list_del(), list_head::next, and list_head::prev.

00114                                                         {
00115         __list_del ( entry->prev, entry->next );
00116 }

static int list_empty ( const struct list_head head  )  [inline, static]


Generated on Tue Apr 6 20:01:51 2010 for gPXE by  doxygen 1.5.7.1