33 #ifndef OPENOCD_HELPER_LIST_H
34 #define OPENOCD_HELPER_LIST_H
47 #define LIST_HEAD_INIT(name) { &(name), &(name) }
49 #define LIST_HEAD(name) \
50 struct list_head name = LIST_HEAD_INIT(name)
62 return (head->
next == head);
95 new->next = old->
next;
125 #define list_entry(ptr, type, field) container_of(ptr, type, field)
127 #define list_first_entry(ptr, type, member) \
128 list_entry((ptr)->next, type, member)
130 #define list_last_entry(ptr, type, member) \
131 list_entry((ptr)->prev, type, member)
133 #define list_first_entry_or_null(ptr, type, member) \
134 (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
136 #define list_next_entry(ptr, member) \
137 list_entry(((ptr)->member.next), typeof(*(ptr)), member)
139 #define list_safe_reset_next(ptr, n, member) \
140 (n) = list_next_entry(ptr, member)
142 #define list_prev_entry(ptr, member) \
143 list_entry(((ptr)->member.prev), typeof(*(ptr)), member)
145 #define list_for_each(p, head) \
146 for (p = (head)->next; p != (head); p = (p)->next)
148 #define list_for_each_safe(p, n, head) \
149 for (p = (head)->next, n = (p)->next; p != (head); p = n, n = (p)->next)
151 #define list_for_each_entry(p, h, field) \
152 for (p = list_entry((h)->next, typeof(*p), field); &(p)->field != (h); \
153 p = list_entry((p)->field.next, typeof(*p), field))
155 #define list_for_each_entry_safe(p, n, h, field) \
156 for (p = list_entry((h)->next, typeof(*p), field), \
157 n = list_entry((p)->field.next, typeof(*p), field); &(p)->field != (h);\
158 p = n, n = list_entry(n->field.next, typeof(*n), field))
160 #define list_for_each_entry_from(p, h, field) \
161 for ( ; &(p)->field != (h); \
162 p = list_entry((p)->field.next, typeof(*p), field))
164 #define list_for_each_entry_continue(p, h, field) \
165 for (p = list_next_entry((p), field); &(p)->field != (h); \
166 p = list_next_entry((p), field))
168 #define list_for_each_entry_safe_from(pos, n, head, member) \
169 for (n = list_entry((pos)->member.next, typeof(*pos), member); \
170 &(pos)->member != (head); \
171 pos = n, n = list_entry(n->member.next, typeof(*n), member))
173 #define list_for_each_entry_reverse(p, h, field) \
174 for (p = list_entry((h)->prev, typeof(*p), field); &(p)->field != (h); \
175 p = list_entry((p)->field.prev, typeof(*p), field))
177 #define list_for_each_entry_safe_reverse(p, n, h, field) \
178 for (p = list_entry((h)->prev, typeof(*p), field), \
179 n = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
180 p = n, n = list_entry(n->field.prev, typeof(*n), field))
182 #define list_for_each_entry_continue_reverse(p, h, field) \
183 for (p = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
184 p = list_entry((p)->field.prev, typeof(*p), field))
186 #define list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = (p)->prev)
188 #define list_for_each_entry_from_reverse(p, h, field) \
189 for (; &p->field != (h); \
190 p = list_prev_entry(p, field))
297 head->
next = new_first;
298 new_first->
prev = head;
307 (head->
next != entry && head != entry))
318 return (list->
prev == head);
324 return list->
next == head;
355 #define list_for_each_entry_direction(is_fwd, p, h, field) \
356 for (p = list_entry(is_fwd ? (h)->next : (h)->prev, typeof(*p), field); \
357 &(p)->field != (h); \
358 p = list_entry(is_fwd ? (p)->field.next : (p)->field.prev, typeof(*p), field))
static void list_add(struct list_head *new, struct list_head *head)
static void list_splice(const struct list_head *list, struct list_head *head)
static void list_bulk_move_tail(struct list_head *head, struct list_head *first, struct list_head *last)
static void __list_cut_position(struct list_head *list, struct list_head *head, struct list_head *entry)
static void list_splice_tail_init(struct list_head *list, struct list_head *head)
static void list_move_tail(struct list_head *entry, struct list_head *head)
static void __list_del(struct list_head *prev, struct list_head *next)
static void list_replace_init(struct list_head *old, struct list_head *new)
static int list_is_first(const struct list_head *list, const struct list_head *head)
static void linux_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
static void list_replace(struct list_head *old, struct list_head *new)
static int list_is_singular(const struct list_head *head)
static void list_add_tail(struct list_head *new, struct list_head *head)
static int list_empty(const struct list_head *head)
static void linux_list_splice(const struct list_head *list, struct list_head *prev, struct list_head *next)
static void list_cut_position(struct list_head *list, struct list_head *head, struct list_head *entry)
#define list_for_each(p, head)
static void list_splice_init(struct list_head *list, struct list_head *head)
static size_t list_count_nodes(const struct list_head *list)
static void __list_del_entry(struct list_head *entry)
static void list_del(struct list_head *entry)
static int list_empty_careful(const struct list_head *head)
static void list_rotate_to_front(struct list_head *entry, struct list_head *head)
static int list_is_last(const struct list_head *list, const struct list_head *head)
static void list_rotate_left(struct list_head *h)
list_rotate_left - rotate the list to the left
static void list_del_init(struct list_head *entry)
static void list_splice_tail(struct list_head *list, struct list_head *head)
static void INIT_LIST_HEAD(struct list_head *list)
static void list_move(struct list_head *list, struct list_head *head)
static uint32_t lh(unsigned int rd, unsigned int base, uint16_t offset) __attribute__((unused))