x86/xen: resume timer irqs early
[linux/fpc-iii.git] / tools / perf / util / intlist.h
blob62351dad848f76c478cced833c315cc71ff1ed63
1 #ifndef __PERF_INTLIST_H
2 #define __PERF_INTLIST_H
4 #include <linux/rbtree.h>
5 #include <stdbool.h>
7 #include "rblist.h"
9 struct int_node {
10 struct rb_node rb_node;
11 int i;
14 struct intlist {
15 struct rblist rblist;
18 struct intlist *intlist__new(const char *slist);
19 void intlist__delete(struct intlist *ilist);
21 void intlist__remove(struct intlist *ilist, struct int_node *in);
22 int intlist__add(struct intlist *ilist, int i);
24 struct int_node *intlist__entry(const struct intlist *ilist, unsigned int idx);
25 struct int_node *intlist__find(struct intlist *ilist, int i);
27 static inline bool intlist__has_entry(struct intlist *ilist, int i)
29 return intlist__find(ilist, i) != NULL;
32 static inline bool intlist__empty(const struct intlist *ilist)
34 return rblist__empty(&ilist->rblist);
37 static inline unsigned int intlist__nr_entries(const struct intlist *ilist)
39 return rblist__nr_entries(&ilist->rblist);
42 /* For intlist iteration */
43 static inline struct int_node *intlist__first(struct intlist *ilist)
45 struct rb_node *rn = rb_first(&ilist->rblist.entries);
46 return rn ? rb_entry(rn, struct int_node, rb_node) : NULL;
48 static inline struct int_node *intlist__next(struct int_node *in)
50 struct rb_node *rn;
51 if (!in)
52 return NULL;
53 rn = rb_next(&in->rb_node);
54 return rn ? rb_entry(rn, struct int_node, rb_node) : NULL;
57 /**
58 * intlist_for_each - iterate over a intlist
59 * @pos: the &struct int_node to use as a loop cursor.
60 * @ilist: the &struct intlist for loop.
62 #define intlist__for_each(pos, ilist) \
63 for (pos = intlist__first(ilist); pos; pos = intlist__next(pos))
65 /**
66 * intlist_for_each_safe - iterate over a intlist safe against removal of
67 * int_node
68 * @pos: the &struct int_node to use as a loop cursor.
69 * @n: another &struct int_node to use as temporary storage.
70 * @ilist: the &struct intlist for loop.
72 #define intlist__for_each_safe(pos, n, ilist) \
73 for (pos = intlist__first(ilist), n = intlist__next(pos); pos;\
74 pos = n, n = intlist__next(n))
75 #endif /* __PERF_INTLIST_H */