1 |
\chapter{List} |
\chapter{Lists} |
2 |
|
Linux provides simple doubly linked list implementation for various internal uses. The main header file is \url{include/linux/list.h}. The structure used to implement the list is \texttt{struct list\_head}. It is defined as: |
3 |
|
\begin{verbatim} |
4 |
|
struct list_head { |
5 |
|
struct list_head *next, *prev; |
6 |
|
}; |
7 |
|
\end{verbatim} |
8 |
|
The \texttt{list} member of the \texttt{struct page} is of the above type and is used to link up pages in various lists such as the per zone \textit{free\_list}. |
9 |
|
|
10 |
|
|
11 |
|
\section{list\_entry}\label{mac:me} |
12 |
|
\textit{Macro: } |
13 |
|
\begin{verbatim} |
14 |
|
#define list_entry(ptr, type, member) \ |
15 |
|
((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) |
16 |
|
\end{verbatim} |
17 |
|
This macro is used to return the pointer to the structure being linked [remember, \textit{list} is a member of \texttt{struct page} and it is used to point to other list members and not the pages themselves]. |
18 |
|
|