- 浏览: 75040 次
- 性别:
- 来自: 北京
#ifndef _LIST_H_ #define _LIST_H_ /* simple (cyclic) doubly linked list borrowed from linux 2.4 */ struct list_head { struct list_head *next, *prev; }; #define LIST_HEAD_INIT(name) { &(name), &(name) } #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) #define INIT_LIST_HEAD(ptr) do { \ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ } while (0) /* * Insert a new entry between two known consecutive entries. * * This is only for internal list manipulation where we know * the prev/next entries already! */ static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { next->prev = new; new->next = next; new->prev = prev; prev->next = new; } /** * list_add - add a new entry * @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. */ static inline void list_add(struct list_head *new, struct list_head *head) { __list_add(new, head, head->next); } /** * list_add_tail - add a new entry * @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. */ static inline void list_add_tail(struct list_head *new, struct list_head *head) { __list_add(new, head->prev, head); } /* * Delete a list entry by making the prev/next entries * point to each other. * * This is only for internal list manipulation where we know * the prev/next entries already! */ static inline void __list_del(struct list_head *prev, struct list_head *next) { next->prev = prev; prev->next = next; } /** * list_del - deletes entry from list. * @entry: the element to delete from the list. * Note: list_empty on entry does not return true after this, the entry is in an undefined state. */ static inline void list_del(struct list_head *entry) { __list_del(entry->prev, entry->next); entry->next = (void *) 0; entry->prev = (void *) 0; } /** * list_del_init - deletes entry from list and reinitialize it. * @entry: the element to delete from the list. */ static inline void list_del_init(struct list_head *entry) { __list_del(entry->prev, entry->next); INIT_LIST_HEAD(entry); } /** * list_move - delete from one list and add as another's head * @list: the entry to move * @head: the head that will precede our entry */ static inline void list_move(struct list_head *list, struct list_head *head) { __list_del(list->prev, list->next); list_add(list, head); } /** * list_move_tail - delete from one list and add as another's tail * @list: the entry to move * @head: the head that will follow our entry */ static inline void list_move_tail(struct list_head *list, struct list_head *head) { __list_del(list->prev, list->next); list_add_tail(list, head); } /** * list_empty - tests whether a list is empty * @head: the list to test. */ static inline int list_empty(struct list_head *head) { return head->next == head; } static inline void __list_splice(struct list_head *list, struct list_head *head) { struct list_head *first = list->next; struct list_head *last = list->prev; struct list_head *at = head->next; first->prev = head; head->next = first; last->next = at; at->prev = last; } /** * list_splice - join two lists * @list: the new list to add. * @head: the place to add it in the first list. */ static inline void list_splice(struct list_head *list, struct list_head *head) { if (!list_empty(list)) __list_splice(list, head); } /** * list_splice_init - join two lists and reinitialise the emptied list. * @list: the new list to add. * @head: the place to add it in the first list. * * The list at @list is reinitialised */ static inline void list_splice_init(struct list_head *list, struct list_head *head) { if (!list_empty(list)) { __list_splice(list, head); INIT_LIST_HEAD(list); } } /** * 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 list_entry(ptr, type, member) \ ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) /** * list_for_each - iterate over a list * @pos: the &struct list_head to use as a loop counter. * @head: the head for your list. */ #define list_for_each(pos, head) \ for (pos = (head)->next; pos != (head); pos = pos->next) /** * list_for_each_prev - iterate over a list backwards * @pos: the &struct list_head to use as a loop counter. * @head: the head for your list. */ #define list_for_each_prev(pos, head) \ for (pos = (head)->prev; pos != (head); pos = pos->prev) /** * list_for_each_safe - iterate over a list safe against removal of list entry * @pos: the &struct list_head to use as a loop counter. * @n: another &struct list_head to use as temporary storage * @head: the head for your list. */ #define list_for_each_safe(pos, n, head) \ for (pos = (head)->next, n = pos->next; pos != (head); \ pos = n, n = pos->next) #endif
发表评论
-
排序算法---计数排序
2011-11-27 14:57 602#include <stdio.h> vo ... -
排序算法---归并排序
2011-11-26 19:33 740#include <stdio.h> vo ... -
排序算法---交换排序(冒泡排序、快速排序)
2011-11-26 19:32 699#include <stdio.h> vo ... -
排序算法---选择排序(简单插入排序、堆排序)
2011-11-26 19:31 643#include <stdio.h> vo ... -
排序算法---插入排序(简单排序、shell排序)
2011-11-26 19:29 643#include <stdio.h> vo ... -
删除字符串中的特定字符和重复字符
2011-11-26 13:45 660#include <stdio.h> vo ... -
Linux编程-多线程、同步和互斥(转载)
2011-11-14 15:27 1204http://www.cnblogs.com/skynet/a ... -
寻找字符串中的最大数字子串
2011-09-22 17:17 1513#include <stdio.h> int f ... -
删除子字符串
2011-09-21 15:27 599#include <stdio.h> #incl ... -
c语言随机数
2011-09-18 17:15 682#include <stdio.h> #i ... -
带头结点有序单链表的合并
2011-09-08 14:21 1178typedef int Item; typedef s ... -
链表逆序的递归/非递归算法
2011-09-01 23:37 1404/** *链表逆序的递归/非递归算法 */ # ... -
递归算法---字符串---全/部分组合和全排列
2011-08-30 23:01 1216#include <stdio.h> #i ... -
递归算法---0-1背包问题(面试宝典)
2011-08-28 21:11 1892/** *正整数n,m,从数列1、2、3、...、n中随 ... -
递归算法---字符串全组合(面试宝典)
2011-08-28 17:24 1249/** *求一字符串所有字串的组合 */ #i ... -
递归算法---求解多元一次方程
2011-08-28 10:38 1892/** * 求解x1+x2+x3+...+x10 = ... -
(zz)关于类的sizeof
2011-08-27 18:16 563http://blog.sina.com.cn/s/blog_ ... -
(zz)结构体字节对齐原则
2011-08-27 17:53 1575结构体默认的字节对齐一般满足三个准则: 结构体变量的首 ... -
The C Programming Lang (K&R) hash table
2011-08-25 09:52 929hash.h #include <stdio.h ... -
Josephus环
2011-08-23 11:20 695/*************************** ...
相关推荐
4. **Linux Linked List Implementation (Section 2.4):** - Linked lists are a fundamental data structure used extensively in the Linux kernel. This section covers the implementation details of linked ...
PEP 366: Explicit Relative Imports From a Main Module PEP 370: Per-user site-packages Directory PEP 371: The multiprocessing Package PEP 3101: Advanced String Formatting PEP 3105: print As a ...
Building a Dict from a List of Alternating Keys and Values Recipe 4.13. Extracting a Subset of a Dictionary Recipe 4.14. Inverting a Dictionary Recipe 4.15. Associating Multiple Values with ...
这一部分着重讨论了如何准备驱动程序以便于将其提交给Linux Kernel Mailing List (LKML)并最终纳入主干内核中: 1. **驱动程序的准备工作**: - 清理代码:确保代码遵循内核编程规范,消除潜在的错误和警告。 - ...
2.3 Installing Go on a Linux system...............................................................................16 2.4 Installing Go on an OS X system..................................................
2.3 Installing Go on a Linux system...............................................................................16 2.4 Installing Go on an OS X system..................................................
- Fix interrupt vectors for INT 60h-66h (reserved for user interrupt) by setting them to zero - Fix BIOS INT13 function 08 when the number of cylinders on the disk = 1 - I/O Devices - USB HP ...
Reading repository metadata in from local files Installed Packages 4Suite.i386 1.0-8.b1 installed Canna.i386 3.7p3-13 installed Canna-devel.i386 3.7p3-13 installed ``` 2. **获取软件包详细信息**:...
2.4. 万物皆对象 2.4.1. 模块导入的搜索路径 2.4.2. 何谓对象? 2.5. 代码缩进 2.6. 测试模块 3. 内置数据类型 3.1. Dictionary 介绍 3.1.1. Dictionary 的定义 3.1.2. Dictionary 的修改 3.1.3. 从 ...
// $Id: INSTALL.txt,v 1.61.2.4 2008/07/09 19:15:59 goba Exp $ CONTENTS OF THIS FILE --------------------- * Requirements * Optional requirements * Installation * Drupal administration * ...
2.4. 万物皆对象 ...................................................................................................... 21 2.5. 代码缩进 ...................................................................
此书对于linux环境编程的同志应该是必读的书,目录如下: Copyright Praise for Advanced Programming in the UNIX® Environment, Second Edition Praise for the First Edition Addison-Wesley ...
2.4. 万物皆对象......................................................................................................21 2.5. 代码缩进....................................................................
2.4. 验证Maven安装 2.5. Maven安装细节 2.5.1. 用户相关配置和仓库 2.5.2. 升级Maven 2.6. 获得Maven帮助 2.7. 使用Maven Help插件 2.7.1. 描述一个Maven插件 2.8. 关于Apache软件许可证 I. Maven实战...
In file included from hardware/broadcom/libbt/include/bt_vendor_brcm.h:34:0, from hardware/broadcom/libbt/src/upio.c:36: out/target/product/tulip-d1/obj_arm/SHARED_LIBRARIES/libbt-vendor_...
5. utf8.c里添加qqdef.h头文件。 Version 3.13 (2009-3-29) 1. Linux(Ubuntu) version compiled! Version 3.12 (2009-3-22) 1. 用Windows的Sleep代替不推荐的_sleep。 2. 在Mingw32-gcc4.3.3上编译成功。 Version...
4.4.3. Excluding Items from the Commit List 4.4.4. 提交日志信息 4.4.5. 提交进程 4.5. 用来自别人的修改更新你的工作副本 4.6. 解决冲突 4.6.1. File Conflicts 4.6.2. Tree Conflicts 4.6.2.1. Local ...