内核双向链表list.h中的list_entry
2011-12-31 17:31
351 查看
内核双向链表list.h中的list_entry定义:
#define list_entry(ptr, type, member) container_of(ptr, type, member)
程序注释为:
/**
* list_entry - get the struct for this entry
* @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.
*/
刚开始没有理解。
现在明白,注释的意思是从一个实体中得到它的结构体。
#define container_of(ptr, type, member) ({const typeof( ((type *)0)->member ) *__mptr = (ptr); (type *)( (char *)__mptr - offsetof(type,member) );})
#define list_entry(ptr, type, member) container_of(ptr, type, member)
程序注释为:
/**
* list_entry - get the struct for this entry
* @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.
*/
刚开始没有理解。
现在明白,注释的意思是从一个实体中得到它的结构体。
#define container_of(ptr, type, member) ({const typeof( ((type *)0)->member ) *__mptr = (ptr); (type *)( (char *)__mptr - offsetof(type,member) );})
相关文章推荐
- Linux 内核中双向链表及list.h 文件分析
- 详解Linux内核之双向循环链表(2) list_for_each/list_entry/list_for_each_entry
- linux 2.4内核中双向链表的实现/include/linux/list.h
- 内核链表中list_entry()函数
- windows驱动开发学习笔记一双向链表LIST_ENTRY
- linux内核部件--通用双向链表list
- 通用链表(内核双向循环链表list_head)
- linux内核学习(17)内核编程基本功之内核链表list_entry
- linux内核学习(17)内核编程基本功之内核链表list_entry
- 内核链表list_entry()宏详解
- 内核中常用的双向链表数据结构(list_head)详解
- linux 内核常用数据结构及算法——list(循环双向链表)
- 深入分析 Linux 内核链表 list_entry...
- (Linux 内核)双向循环链表list_head
- linux 内核分析之list_head 双向链表结构
- list_for_each & list_entry & 对内核链表的理解
- container_of()和内核链表中的list_entry()
- 深入分析 Linux 内核链表 list_entry...
- 深度剖析linux内核万能--双向链表,Hash链表模版
- 数据结构:双向链表list的表头/尾添加数据、链表显示、链表清空