• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/support/kconfig/list.h
Yann E. MORINYann E. MORIN committed b48e35a28a614 Nov 2013
Raw file
Source viewDiff to previous
 
1
#ifndef LIST_H
2
#define LIST_H
3
​
4
/*
5
 * Copied from include/linux/...
6
 */
7
​
8
#undef offsetof
9
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
10
​
11
/**
12
 * container_of - cast a member of a structure out to the containing structure
13
 * @ptr:        the pointer to the member.
14
 * @type:       the type of the container struct this is embedded in.
15
 * @member:     the name of the member within the struct.
16
 *
17
 */
18
#define container_of(ptr, type, member) ({                      \
19
    const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
20
    (type *)( (char *)__mptr - offsetof(type,member) );})
21
​
22
​
23
struct list_head {
24
    struct list_head *next, *prev;
25
};
26
​
27
​
28
#define LIST_HEAD_INIT(name) { &(name), &(name) }
29
​
30
#define LIST_HEAD(name) \
31
    struct list_head name = LIST_HEAD_INIT(name)
32
​
33
/**
34
 * list_entry - get the struct for this entry
35
 * @ptr:    the &struct list_head pointer.
36
 * @type:   the type of the struct this is embedded in.
37
 * @member: the name of the list_struct within the struct.
38
 */
39
#define list_entry(ptr, type, member) \
40
    container_of(ptr, type, member)
41
​
42
/**
43
 * list_for_each_entry  -   iterate over list of given type
44
 * @pos:    the type * to use as a loop cursor.
45
 * @head:   the head for your list.
46
 * @member: the name of the list_struct within the struct.
47
 */
48
#define list_for_each_entry(pos, head, member)              \
49
    for (pos = list_entry((head)->next, typeof(*pos), member);  \
50
         &pos->member != (head);    \
51
         pos = list_entry(pos->member.next, typeof(*pos), member))
52
​
53
/**
54
 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
55
 * @pos:    the type * to use as a loop cursor.
56
 * @n:      another type * to use as temporary storage
57
 * @head:   the head for your list.
58
 * @member: the name of the list_struct within the struct.
59
 */
60
#define list_for_each_entry_safe(pos, n, head, member)          \
61
    for (pos = list_entry((head)->next, typeof(*pos), member),  \
62
        n = list_entry(pos->member.next, typeof(*pos), member); \
63
         &pos->member != (head);                    \
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.