target: rtt: include rtt.h
[openocd.git] / src / helper / list.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 /*
4 * The content of this file is mainly copied/inspired from Linux kernel
5 * code in include/linux/list.h, include/linux/types.h
6 * Last aligned with kernel v5.12:
7 * - skip the functions hlist_unhashed_lockless() and __list_del_clearprev()
8 * that are relevant only in kernel;
9 * - Remove non-standard GCC extension "omitted conditional operand" from
10 * list_prepare_entry;
11 * - expand READ_ONCE, WRITE_ONCE, smp_load_acquire, smp_store_release;
12 * - make comments compatible with doxygen.
13 *
14 * There is an example of using this file in contrib/list_example.c.
15 */
16
17 #ifndef OPENOCD_HELPER_LIST_H
18 #define OPENOCD_HELPER_LIST_H
19
20 /* begin local changes */
21 #include <helper/types.h>
22
23 #define LIST_POISON1 NULL
24 #define LIST_POISON2 NULL
25
26 struct list_head {
27 struct list_head *next, *prev;
28 };
29
30 /* end local changes */
31
32 /*
33 * Circular doubly linked list implementation.
34 *
35 * Some of the internal functions ("__xxx") are useful when
36 * manipulating whole lists rather than single entries, as
37 * sometimes we already know the next/prev entries and we can
38 * generate better code by using them directly rather than
39 * using the generic single-entry routines.
40 */
41
42 #define LIST_HEAD_INIT(name) { &(name), &(name) }
43
44 #define LIST_HEAD(name) \
45 struct list_head name = LIST_HEAD_INIT(name)
46
47 /**
48 * INIT_LIST_HEAD - Initialize a list_head structure
49 * @param list list_head structure to be initialized.
50 *
51 * Initializes the list_head to point to itself. If it is a list header,
52 * the result is an empty list.
53 */
54 static inline void INIT_LIST_HEAD(struct list_head *list)
55 {
56 list->next = list;
57 list->prev = list;
58 }
59
60 #ifdef CONFIG_DEBUG_LIST
61 extern bool __list_add_valid(struct list_head *new,
62 struct list_head *prev,
63 struct list_head *next);
64 extern bool __list_del_entry_valid(struct list_head *entry);
65 #else
66 static inline bool __list_add_valid(struct list_head *new,
67 struct list_head *prev,
68 struct list_head *next)
69 {
70 return true;
71 }
72 static inline bool __list_del_entry_valid(struct list_head *entry)
73 {
74 return true;
75 }
76 #endif
77
78 /*
79 * Insert a new entry between two known consecutive entries.
80 *
81 * This is only for internal list manipulation where we know
82 * the prev/next entries already!
83 */
84 static inline void __list_add(struct list_head *new,
85 struct list_head *prev,
86 struct list_head *next)
87 {
88 if (!__list_add_valid(new, prev, next))
89 return;
90
91 next->prev = new;
92 new->next = next;
93 new->prev = prev;
94 prev->next = new;
95 }
96
97 /**
98 * list_add - add a new entry
99 * @param new new entry to be added
100 * @param head list head to add it after
101 *
102 * Insert a new entry after the specified head.
103 * This is good for implementing stacks.
104 */
105 static inline void list_add(struct list_head *new, struct list_head *head)
106 {
107 __list_add(new, head, head->next);
108 }
109
110
111 /**
112 * list_add_tail - add a new entry
113 * @param new new entry to be added
114 * @param head list head to add it before
115 *
116 * Insert a new entry before the specified head.
117 * This is useful for implementing queues.
118 */
119 static inline void list_add_tail(struct list_head *new, struct list_head *head)
120 {
121 __list_add(new, head->prev, head);
122 }
123
124 /*
125 * Delete a list entry by making the prev/next entries
126 * point to each other.
127 *
128 * This is only for internal list manipulation where we know
129 * the prev/next entries already!
130 */
131 static inline void __list_del(struct list_head *prev, struct list_head *next)
132 {
133 next->prev = prev;
134 prev->next = next;
135 }
136
137 /* Ignore kernel __list_del_clearprev() */
138
139 static inline void __list_del_entry(struct list_head *entry)
140 {
141 if (!__list_del_entry_valid(entry))
142 return;
143
144 __list_del(entry->prev, entry->next);
145 }
146
147 /**
148 * list_del - deletes entry from list.
149 * @param entry the element to delete from the list.
150 * Note: list_empty() on entry does not return true after this, the entry is
151 * in an undefined state.
152 */
153 static inline void list_del(struct list_head *entry)
154 {
155 __list_del_entry(entry);
156 entry->next = LIST_POISON1;
157 entry->prev = LIST_POISON2;
158 }
159
160 /**
161 * list_replace - replace old entry by new one
162 * @param old the element to be replaced
163 * @param new the new element to insert
164 *
165 * If @a old was empty, it will be overwritten.
166 */
167 static inline void list_replace(struct list_head *old,
168 struct list_head *new)
169 {
170 new->next = old->next;
171 new->next->prev = new;
172 new->prev = old->prev;
173 new->prev->next = new;
174 }
175
176 /**
177 * list_replace_init - replace old entry by new one and initialize the old one
178 * @param old the element to be replaced
179 * @param new the new element to insert
180 *
181 * If @a old was empty, it will be overwritten.
182 */
183 static inline void list_replace_init(struct list_head *old,
184 struct list_head *new)
185 {
186 list_replace(old, new);
187 INIT_LIST_HEAD(old);
188 }
189
190 /**
191 * list_swap - replace entry1 with entry2 and re-add entry1 at entry2's position
192 * @param entry1 the location to place entry2
193 * @param entry2 the location to place entry1
194 */
195 static inline void list_swap(struct list_head *entry1,
196 struct list_head *entry2)
197 {
198 struct list_head *pos = entry2->prev;
199
200 list_del(entry2);
201 list_replace(entry1, entry2);
202 if (pos == entry1)
203 pos = entry2;
204 list_add(entry1, pos);
205 }
206
207 /**
208 * list_del_init - deletes entry from list and reinitialize it.
209 * @param entry the element to delete from the list.
210 */
211 static inline void list_del_init(struct list_head *entry)
212 {
213 __list_del_entry(entry);
214 INIT_LIST_HEAD(entry);
215 }
216
217 /**
218 * list_move - delete from one list and add as another's head
219 * @param list the entry to move
220 * @param head the head that will precede our entry
221 */
222 static inline void list_move(struct list_head *list, struct list_head *head)
223 {
224 __list_del_entry(list);
225 list_add(list, head);
226 }
227
228 /**
229 * list_move_tail - delete from one list and add as another's tail
230 * @param list the entry to move
231 * @param head the head that will follow our entry
232 */
233 static inline void list_move_tail(struct list_head *list,
234 struct list_head *head)
235 {
236 __list_del_entry(list);
237 list_add_tail(list, head);
238 }
239
240 /**
241 * list_bulk_move_tail - move a subsection of a list to its tail
242 * @param head the head that will follow our entry
243 * @param first the first entry to move
244 * @param last the last entry to move, can be the same as first
245 *
246 * Move all entries between @a first and including @a last before @a head.
247 * All three entries must belong to the same linked list.
248 */
249 static inline void list_bulk_move_tail(struct list_head *head,
250 struct list_head *first,
251 struct list_head *last)
252 {
253 first->prev->next = last->next;
254 last->next->prev = first->prev;
255
256 head->prev->next = first;
257 first->prev = head->prev;
258
259 last->next = head;
260 head->prev = last;
261 }
262
263 /**
264 * list_is_first -- tests whether @a list is the first entry in list @a head
265 * @param list the entry to test
266 * @param head the head of the list
267 */
268 static inline int list_is_first(const struct list_head *list, const struct list_head *head)
269 {
270 return list->prev == head;
271 }
272
273 /**
274 * list_is_last - tests whether @a list is the last entry in list @a head
275 * @param list the entry to test
276 * @param head the head of the list
277 */
278 static inline int list_is_last(const struct list_head *list, const struct list_head *head)
279 {
280 return list->next == head;
281 }
282
283 /**
284 * list_is_head - tests whether @a list is the list @a head
285 * @param list the entry to test
286 * @param head the head of the list
287 */
288 static inline int list_is_head(const struct list_head *list, const struct list_head *head)
289 {
290 return list == head;
291 }
292
293 /**
294 * list_empty - tests whether a list is empty
295 * @param head the list to test.
296 */
297 static inline int list_empty(const struct list_head *head)
298 {
299 return head->next == head;
300 }
301
302 /**
303 * list_del_init_careful - deletes entry from list and reinitialize it.
304 * @param entry the element to delete from the list.
305 *
306 * This is the same as list_del_init(), except designed to be used
307 * together with list_empty_careful() in a way to guarantee ordering
308 * of other memory operations.
309 *
310 * Any memory operations done before a list_del_init_careful() are
311 * guaranteed to be visible after a list_empty_careful() test.
312 */
313 static inline void list_del_init_careful(struct list_head *entry)
314 {
315 __list_del_entry(entry);
316 entry->prev = entry;
317 entry->next = entry;
318 }
319
320 /**
321 * list_empty_careful - tests whether a list is empty and not being modified
322 * @param head the list to test
323 *
324 * Description:
325 * tests whether a list is empty _and_ checks that no other CPU might be
326 * in the process of modifying either member (next or prev)
327 *
328 * NOTE: using list_empty_careful() without synchronization
329 * can only be safe if the only activity that can happen
330 * to the list entry is list_del_init(). Eg. it cannot be used
331 * if another CPU could re-list_add() it.
332 */
333 static inline int list_empty_careful(const struct list_head *head)
334 {
335 struct list_head *next = head->next;
336 return (next == head) && (next == head->prev);
337 }
338
339 /**
340 * list_rotate_left - rotate the list to the left
341 * @param head the head of the list
342 */
343 static inline void list_rotate_left(struct list_head *head)
344 {
345 struct list_head *first;
346
347 if (!list_empty(head)) {
348 first = head->next;
349 list_move_tail(first, head);
350 }
351 }
352
353 /**
354 * list_rotate_to_front() - Rotate list to specific item.
355 * @param list The desired new front of the list.
356 * @param head The head of the list.
357 *
358 * Rotates list so that @a list becomes the new front of the list.
359 */
360 static inline void list_rotate_to_front(struct list_head *list,
361 struct list_head *head)
362 {
363 /*
364 * Deletes the list head from the list denoted by @a head and
365 * places it as the tail of @a list, this effectively rotates the
366 * list so that @a list is at the front.
367 */
368 list_move_tail(head, list);
369 }
370
371 /**
372 * list_is_singular - tests whether a list has just one entry.
373 * @param head the list to test.
374 */
375 static inline int list_is_singular(const struct list_head *head)
376 {
377 return !list_empty(head) && (head->next == head->prev);
378 }
379
380 static inline void __list_cut_position(struct list_head *list,
381 struct list_head *head, struct list_head *entry)
382 {
383 struct list_head *new_first = entry->next;
384 list->next = head->next;
385 list->next->prev = list;
386 list->prev = entry;
387 entry->next = list;
388 head->next = new_first;
389 new_first->prev = head;
390 }
391
392 /**
393 * list_cut_position - cut a list into two
394 * @param list a new list to add all removed entries
395 * @param head a list with entries
396 * @param entry an entry within head, could be the head itself
397 * and if so we won't cut the list
398 *
399 * This helper moves the initial part of @a head, up to and
400 * including @a entry, from @a head to @a list. You should
401 * pass on @a entry an element you know is on @a head. @a list
402 * should be an empty list or a list you do not care about
403 * losing its data.
404 *
405 */
406 static inline void list_cut_position(struct list_head *list,
407 struct list_head *head, struct list_head *entry)
408 {
409 if (list_empty(head))
410 return;
411 if (list_is_singular(head) && !list_is_head(entry, head) && (entry != head->next))
412 return;
413 if (list_is_head(entry, head))
414 INIT_LIST_HEAD(list);
415 else
416 __list_cut_position(list, head, entry);
417 }
418
419 /**
420 * list_cut_before - cut a list into two, before given entry
421 * @param list a new list to add all removed entries
422 * @param head a list with entries
423 * @param entry an entry within head, could be the head itself
424 *
425 * This helper moves the initial part of @a head, up to but
426 * excluding @a entry, from @a head to @a list. You should pass
427 * in @a entry an element you know is on @a head. @a list should
428 * be an empty list or a list you do not care about losing
429 * its data.
430 * If @a entry == @a head, all entries on @a head are moved to
431 * @a list.
432 */
433 static inline void list_cut_before(struct list_head *list,
434 struct list_head *head,
435 struct list_head *entry)
436 {
437 if (head->next == entry) {
438 INIT_LIST_HEAD(list);
439 return;
440 }
441 list->next = head->next;
442 list->next->prev = list;
443 list->prev = entry->prev;
444 list->prev->next = list;
445 head->next = entry;
446 entry->prev = head;
447 }
448
449 static inline void __list_splice(const struct list_head *list,
450 struct list_head *prev,
451 struct list_head *next)
452 {
453 struct list_head *first = list->next;
454 struct list_head *last = list->prev;
455
456 first->prev = prev;
457 prev->next = first;
458
459 last->next = next;
460 next->prev = last;
461 }
462
463 /**
464 * list_splice - join two lists, this is designed for stacks
465 * @param list the new list to add.
466 * @param head the place to add it in the first list.
467 */
468 static inline void list_splice(const struct list_head *list,
469 struct list_head *head)
470 {
471 if (!list_empty(list))
472 __list_splice(list, head, head->next);
473 }
474
475 /**
476 * list_splice_tail - join two lists, each list being a queue
477 * @param list the new list to add.
478 * @param head the place to add it in the first list.
479 */
480 static inline void list_splice_tail(struct list_head *list,
481 struct list_head *head)
482 {
483 if (!list_empty(list))
484 __list_splice(list, head->prev, head);
485 }
486
487 /**
488 * list_splice_init - join two lists and reinitialise the emptied list.
489 * @param list the new list to add.
490 * @param head the place to add it in the first list.
491 *
492 * The list at @a list is reinitialised
493 */
494 static inline void list_splice_init(struct list_head *list,
495 struct list_head *head)
496 {
497 if (!list_empty(list)) {
498 __list_splice(list, head, head->next);
499 INIT_LIST_HEAD(list);
500 }
501 }
502
503 /**
504 * list_splice_tail_init - join two lists and reinitialise the emptied list
505 * @param list the new list to add.
506 * @param head the place to add it in the first list.
507 *
508 * Each of the lists is a queue.
509 * The list at @a list is reinitialised
510 */
511 static inline void list_splice_tail_init(struct list_head *list,
512 struct list_head *head)
513 {
514 if (!list_empty(list)) {
515 __list_splice(list, head->prev, head);
516 INIT_LIST_HEAD(list);
517 }
518 }
519
520 /**
521 * list_entry - get the struct for this entry
522 * @param ptr the &struct list_head pointer.
523 * @param type the type of the struct this is embedded in.
524 * @param member the name of the list_head within the struct.
525 */
526 #define list_entry(ptr, type, member) \
527 container_of(ptr, type, member)
528
529 /**
530 * list_first_entry - get the first element from a list
531 * @param ptr the list head to take the element from.
532 * @param type the type of the struct this is embedded in.
533 * @param member the name of the list_head within the struct.
534 *
535 * Note, that list is expected to be not empty.
536 */
537 #define list_first_entry(ptr, type, member) \
538 list_entry((ptr)->next, type, member)
539
540 /**
541 * list_last_entry - get the last element from a list
542 * @param ptr the list head to take the element from.
543 * @param type the type of the struct this is embedded in.
544 * @param member the name of the list_head within the struct.
545 *
546 * Note, that list is expected to be not empty.
547 */
548 #define list_last_entry(ptr, type, member) \
549 list_entry((ptr)->prev, type, member)
550
551 /**
552 * list_first_entry_or_null - get the first element from a list
553 * @param ptr the list head to take the element from.
554 * @param type the type of the struct this is embedded in.
555 * @param member the name of the list_head within the struct.
556 *
557 * Note that if the list is empty, it returns NULL.
558 */
559 #define list_first_entry_or_null(ptr, type, member) ({ \
560 struct list_head *head__ = (ptr); \
561 struct list_head *pos__ = head__->next; \
562 pos__ != head__ ? list_entry(pos__, type, member) : NULL; \
563 })
564
565 /**
566 * list_next_entry - get the next element in list
567 * @param pos the type * to cursor
568 * @param member the name of the list_head within the struct.
569 */
570 #define list_next_entry(pos, member) \
571 list_entry((pos)->member.next, typeof(*(pos)), member)
572
573 /**
574 * list_next_entry_circular - get the next element in list
575 * @param pos the type * to cursor.
576 * @param head the list head to take the element from.
577 * @param member the name of the list_head within the struct.
578 *
579 * Wraparound if pos is the last element (return the first element).
580 * Note, that list is expected to be not empty.
581 */
582 #define list_next_entry_circular(pos, head, member) \
583 (list_is_last(&(pos)->member, head) ? \
584 list_first_entry(head, typeof(*(pos)), member) : list_next_entry(pos, member))
585
586 /**
587 * list_prev_entry - get the prev element in list
588 * @param pos the type * to cursor
589 * @param member the name of the list_head within the struct.
590 */
591 #define list_prev_entry(pos, member) \
592 list_entry((pos)->member.prev, typeof(*(pos)), member)
593
594 /**
595 * list_prev_entry_circular - get the prev element in list
596 * @param pos the type * to cursor.
597 * @param head the list head to take the element from.
598 * @param member the name of the list_head within the struct.
599 *
600 * Wraparound if pos is the first element (return the last element).
601 * Note, that list is expected to be not empty.
602 */
603 #define list_prev_entry_circular(pos, head, member) \
604 (list_is_first(&(pos)->member, head) ? \
605 list_last_entry(head, typeof(*(pos)), member) : list_prev_entry(pos, member))
606
607 /**
608 * list_for_each - iterate over a list
609 * @param pos the &struct list_head to use as a loop cursor.
610 * @param head the head for your list.
611 */
612 #define list_for_each(pos, head) \
613 for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next)
614
615 /* Ignore kernel list_for_each_rcu() */
616
617 /**
618 * list_for_each_continue - continue iteration over a list
619 * @param pos the &struct list_head to use as a loop cursor.
620 * @param head the head for your list.
621 *
622 * Continue to iterate over a list, continuing after the current position.
623 */
624 #define list_for_each_continue(pos, head) \
625 for (pos = pos->next; pos != (head); pos = pos->next)
626
627 /**
628 * list_for_each_prev - iterate over a list backwards
629 * @param pos the &struct list_head to use as a loop cursor.
630 * @param head the head for your list.
631 */
632 #define list_for_each_prev(pos, head) \
633 for (pos = (head)->prev; pos != (head); pos = pos->prev)
634
635 /**
636 * list_for_each_safe - iterate over a list safe against removal of list entry
637 * @param pos the &struct list_head to use as a loop cursor.
638 * @param n another &struct list_head to use as temporary storage
639 * @param head the head for your list.
640 */
641 #define list_for_each_safe(pos, n, head) \
642 for (pos = (head)->next, n = pos->next; pos != (head); \
643 pos = n, n = pos->next)
644
645 /**
646 * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
647 * @param pos the &struct list_head to use as a loop cursor.
648 * @param n another &struct list_head to use as temporary storage
649 * @param head the head for your list.
650 */
651 #define list_for_each_prev_safe(pos, n, head) \
652 for (pos = (head)->prev, n = pos->prev; \
653 pos != (head); \
654 pos = n, n = pos->prev)
655
656 /**
657 * list_count_nodes - count nodes in the list
658 * @param head the head for your list.
659 */
660 static inline size_t list_count_nodes(struct list_head *head)
661 {
662 struct list_head *pos;
663 size_t count = 0;
664
665 list_for_each(pos, head)
666 count++;
667
668 return count;
669 }
670
671 /**
672 * list_entry_is_head - test if the entry points to the head of the list
673 * @param pos the type * to cursor
674 * @param head the head for your list.
675 * @param member the name of the list_head within the struct.
676 */
677 #define list_entry_is_head(pos, head, member) \
678 (&pos->member == (head))
679
680 /**
681 * list_for_each_entry - iterate over list of given type
682 * @param pos the type * to use as a loop cursor.
683 * @param head the head for your list.
684 * @param member the name of the list_head within the struct.
685 */
686 #define list_for_each_entry(pos, head, member) \
687 for (pos = list_first_entry(head, typeof(*pos), member); \
688 !list_entry_is_head(pos, head, member); \
689 pos = list_next_entry(pos, member))
690
691 /**
692 * list_for_each_entry_reverse - iterate backwards over list of given type.
693 * @param pos the type * to use as a loop cursor.
694 * @param head the head for your list.
695 * @param member the name of the list_head within the struct.
696 */
697 #define list_for_each_entry_reverse(pos, head, member) \
698 for (pos = list_last_entry(head, typeof(*pos), member); \
699 !list_entry_is_head(pos, head, member); \
700 pos = list_prev_entry(pos, member))
701
702 /**
703 * list_for_each_entry_direction - iterate forward/backward over list of given type
704 * @param forward the iterate direction, true for forward, false for backward.
705 * @param pos the type * to use as a loop cursor.
706 * @param head the head for your list.
707 * @param member the name of the list_head within the struct.
708 */
709 #define list_for_each_entry_direction(forward, pos, head, member) \
710 for (pos = forward ? list_first_entry(head, typeof(*pos), member) \
711 : list_last_entry(head, typeof(*pos), member); \
712 !list_entry_is_head(pos, head, member); \
713 pos = forward ? list_next_entry(pos, member) \
714 : list_prev_entry(pos, member))
715
716 /**
717 * list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
718 * @param pos the type * to use as a start point
719 * @param head the head of the list
720 * @param member the name of the list_head within the struct.
721 *
722 * Prepares a pos entry for use as a start point in list_for_each_entry_continue().
723 */
724 #define list_prepare_entry(pos, head, member) \
725 ((pos) ? (pos) : list_entry(head, typeof(*pos), member))
726
727 /**
728 * list_for_each_entry_continue - continue iteration over list of given type
729 * @param pos the type * to use as a loop cursor.
730 * @param head the head for your list.
731 * @param member the name of the list_head within the struct.
732 *
733 * Continue to iterate over list of given type, continuing after
734 * the current position.
735 */
736 #define list_for_each_entry_continue(pos, head, member) \
737 for (pos = list_next_entry(pos, member); \
738 !list_entry_is_head(pos, head, member); \
739 pos = list_next_entry(pos, member))
740
741 /**
742 * list_for_each_entry_continue_reverse - iterate backwards from the given point
743 * @param pos the type * to use as a loop cursor.
744 * @param head the head for your list.
745 * @param member the name of the list_head within the struct.
746 *
747 * Start to iterate over list of given type backwards, continuing after
748 * the current position.
749 */
750 #define list_for_each_entry_continue_reverse(pos, head, member) \
751 for (pos = list_prev_entry(pos, member); \
752 !list_entry_is_head(pos, head, member); \
753 pos = list_prev_entry(pos, member))
754
755 /**
756 * list_for_each_entry_from - iterate over list of given type from the current point
757 * @param pos the type * to use as a loop cursor.
758 * @param head the head for your list.
759 * @param member the name of the list_head within the struct.
760 *
761 * Iterate over list of given type, continuing from current position.
762 */
763 #define list_for_each_entry_from(pos, head, member) \
764 for (; !list_entry_is_head(pos, head, member); \
765 pos = list_next_entry(pos, member))
766
767 /**
768 * list_for_each_entry_from_reverse - iterate backwards over list of given type
769 * from the current point
770 * @param pos the type * to use as a loop cursor.
771 * @param head the head for your list.
772 * @param member the name of the list_head within the struct.
773 *
774 * Iterate backwards over list of given type, continuing from current position.
775 */
776 #define list_for_each_entry_from_reverse(pos, head, member) \
777 for (; !list_entry_is_head(pos, head, member); \
778 pos = list_prev_entry(pos, member))
779
780 /**
781 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
782 * @param pos the type * to use as a loop cursor.
783 * @param n another type * to use as temporary storage
784 * @param head the head for your list.
785 * @param member the name of the list_head within the struct.
786 */
787 #define list_for_each_entry_safe(pos, n, head, member) \
788 for (pos = list_first_entry(head, typeof(*pos), member), \
789 n = list_next_entry(pos, member); \
790 !list_entry_is_head(pos, head, member); \
791 pos = n, n = list_next_entry(n, member))
792
793 /**
794 * list_for_each_entry_safe_continue - continue list iteration safe against removal
795 * @param pos the type * to use as a loop cursor.
796 * @param n another type * to use as temporary storage
797 * @param head the head for your list.
798 * @param member the name of the list_head within the struct.
799 *
800 * Iterate over list of given type, continuing after current point,
801 * safe against removal of list entry.
802 */
803 #define list_for_each_entry_safe_continue(pos, n, head, member) \
804 for (pos = list_next_entry(pos, member), \
805 n = list_next_entry(pos, member); \
806 !list_entry_is_head(pos, head, member); \
807 pos = n, n = list_next_entry(n, member))
808
809 /**
810 * list_for_each_entry_safe_from - iterate over list from current point safe against removal
811 * @param pos the type * to use as a loop cursor.
812 * @param n another type * to use as temporary storage
813 * @param head the head for your list.
814 * @param member the name of the list_head within the struct.
815 *
816 * Iterate over list of given type from current point, safe against
817 * removal of list entry.
818 */
819 #define list_for_each_entry_safe_from(pos, n, head, member) \
820 for (n = list_next_entry(pos, member); \
821 !list_entry_is_head(pos, head, member); \
822 pos = n, n = list_next_entry(n, member))
823
824 /**
825 * list_for_each_entry_safe_reverse - iterate backwards over list safe against removal
826 * @param pos the type * to use as a loop cursor.
827 * @param n another type * to use as temporary storage
828 * @param head the head for your list.
829 * @param member the name of the list_head within the struct.
830 *
831 * Iterate backwards over list of given type, safe against removal
832 * of list entry.
833 */
834 #define list_for_each_entry_safe_reverse(pos, n, head, member) \
835 for (pos = list_last_entry(head, typeof(*pos), member), \
836 n = list_prev_entry(pos, member); \
837 !list_entry_is_head(pos, head, member); \
838 pos = n, n = list_prev_entry(n, member))
839
840 /**
841 * list_safe_reset_next - reset a stale list_for_each_entry_safe loop
842 * @param pos the loop cursor used in the list_for_each_entry_safe loop
843 * @param n temporary storage used in list_for_each_entry_safe
844 * @param member the name of the list_head within the struct.
845 *
846 * list_safe_reset_next is not safe to use in general if the list may be
847 * modified concurrently (eg. the lock is dropped in the loop body). An
848 * exception to this is if the cursor element (pos) is pinned in the list,
849 * and list_safe_reset_next is called after re-taking the lock and before
850 * completing the current iteration of the loop body.
851 */
852 #define list_safe_reset_next(pos, n, member) \
853 n = list_next_entry(pos, member)
854
855 /*
856 * Double linked lists with a single pointer list head.
857 * IGNORED
858 */
859
860 #endif /* OPENOCD_HELPER_LIST_H */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)