33 #ifndef OPENOCD_HELPER_LIST_H
34 #define OPENOCD_HELPER_LIST_H
48 #define LIST_HEAD_INIT(name) { &(name), &(name) }
50 #define OOCD_LIST_HEAD(name) \
51 struct list_head name = LIST_HEAD_INIT(name)
63 return (head->
next == head);
96 new->next = old->
next;
129 #define list_entry(ptr, type, field) container_of(ptr, type, field)
131 #define list_first_entry(ptr, type, member) \
132 list_entry((ptr)->next, type, member)
134 #define list_last_entry(ptr, type, member) \
135 list_entry((ptr)->prev, type, member)
137 #define list_first_entry_or_null(ptr, type, member) \
138 (!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
140 #define list_next_entry(ptr, member) \
141 list_entry(((ptr)->member.next), typeof(*(ptr)), member)
143 #define list_safe_reset_next(ptr, n, member) \
144 (n) = list_next_entry(ptr, member)
146 #define list_prev_entry(ptr, member) \
147 list_entry(((ptr)->member.prev), typeof(*(ptr)), member)
149 #define list_for_each(p, head) \
150 for (p = (head)->next; p != (head); p = (p)->next)
152 #define list_for_each_safe(p, n, head) \
153 for (p = (head)->next, n = (p)->next; p != (head); p = n, n = (p)->next)
155 #define list_for_each_entry(p, h, field) \
156 for (p = list_entry((h)->next, typeof(*p), field); &(p)->field != (h); \
157 p = list_entry((p)->field.next, typeof(*p), field))
159 #define list_for_each_entry_safe(p, n, h, field) \
160 for (p = list_entry((h)->next, typeof(*p), field), \
161 n = list_entry((p)->field.next, typeof(*p), field); &(p)->field != (h);\
162 p = n, n = list_entry(n->field.next, typeof(*n), field))
164 #define list_for_each_entry_from(p, h, field) \
165 for ( ; &(p)->field != (h); \
166 p = list_entry((p)->field.next, typeof(*p), field))
168 #define list_for_each_entry_continue(p, h, field) \
169 for (p = list_next_entry((p), field); &(p)->field != (h); \
170 p = list_next_entry((p), field))
172 #define list_for_each_entry_safe_from(pos, n, head, member) \
173 for (n = list_entry((pos)->member.next, typeof(*pos), member); \
174 &(pos)->member != (head); \
175 pos = n, n = list_entry(n->member.next, typeof(*n), member))
177 #define list_for_each_entry_reverse(p, h, field) \
178 for (p = list_entry((h)->prev, typeof(*p), field); &(p)->field != (h); \
179 p = list_entry((p)->field.prev, typeof(*p), field))
181 #define list_for_each_entry_safe_reverse(p, n, h, field) \
182 for (p = list_entry((h)->prev, typeof(*p), field), \
183 n = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
184 p = n, n = list_entry(n->field.prev, typeof(*n), field))
186 #define list_for_each_entry_continue_reverse(p, h, field) \
187 for (p = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
188 p = list_entry((p)->field.prev, typeof(*p), field))
190 #define list_for_each_prev(p, h) for (p = (h)->prev; p != (h); p = (p)->prev)
192 #define list_for_each_entry_from_reverse(p, h, field) \
193 for (; &p->field != (h); \
194 p = list_prev_entry(p, field))
301 head->
next = new_first;
302 new_first->
prev = head;
311 (head->
next != entry && head != entry))
322 return (list->
prev == head);
328 return list->
next == head;
359 #define list_for_each_entry_direction(is_fwd, p, h, field) \
360 for (p = list_entry(is_fwd ? (h)->next : (h)->prev, typeof(*p), field); \
361 &(p)->field != (h); \
362 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))