diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2012-09-13 10:41:01 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2012-09-13 10:41:01 -0400 |
commit | 78890b5989d96ddce989cde929c45ceeded0fcaf (patch) | |
tree | 4e2da81fc7c97f11aee174b1eedac110c9a68b3a /tools/perf/util/intlist.c | |
parent | 1959ec5f82acbdf91425b41600f119ebecb5f6a8 (diff) | |
parent | 55d512e245bc7699a8800e23df1a24195dd08217 (diff) |
Merge commit 'v3.6-rc5' into next
* commit 'v3.6-rc5': (1098 commits)
Linux 3.6-rc5
HID: tpkbd: work even if the new Lenovo Keyboard driver is not configured
Remove user-triggerable BUG from mpol_to_str
xen/pciback: Fix proper FLR steps.
uml: fix compile error in deliver_alarm()
dj: memory scribble in logi_dj
Fix order of arguments to compat_put_time[spec|val]
xen: Use correct masking in xen_swiotlb_alloc_coherent.
xen: fix logical error in tlb flushing
xen/p2m: Fix one-off error in checking the P2M tree directory.
powerpc: Don't use __put_user() in patch_instruction
powerpc: Make sure IPI handlers see data written by IPI senders
powerpc: Restore correct DSCR in context switch
powerpc: Fix DSCR inheritance in copy_thread()
powerpc: Keep thread.dscr and thread.dscr_inherit in sync
powerpc: Update DSCR on all CPUs when writing sysfs dscr_default
powerpc/powernv: Always go into nap mode when CPU is offline
powerpc: Give hypervisor decrementer interrupts their own handler
powerpc/vphn: Fix arch_update_cpu_topology() return value
ARM: gemini: fix the gemini build
...
Conflicts:
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
drivers/rapidio/devices/tsi721.c
Diffstat (limited to 'tools/perf/util/intlist.c')
-rw-r--r-- | tools/perf/util/intlist.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/tools/perf/util/intlist.c b/tools/perf/util/intlist.c new file mode 100644 index 000000000000..fd530dced9cb --- /dev/null +++ b/tools/perf/util/intlist.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /* | ||
2 | * Based on intlist.c by: | ||
3 | * (c) 2009 Arnaldo Carvalho de Melo <acme@redhat.com> | ||
4 | * | ||
5 | * Licensed under the GPLv2. | ||
6 | */ | ||
7 | |||
8 | #include <errno.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <linux/compiler.h> | ||
11 | |||
12 | #include "intlist.h" | ||
13 | |||
14 | static struct rb_node *intlist__node_new(struct rblist *rblist __used, | ||
15 | const void *entry) | ||
16 | { | ||
17 | int i = (int)((long)entry); | ||
18 | struct rb_node *rc = NULL; | ||
19 | struct int_node *node = malloc(sizeof(*node)); | ||
20 | |||
21 | if (node != NULL) { | ||
22 | node->i = i; | ||
23 | rc = &node->rb_node; | ||
24 | } | ||
25 | |||
26 | return rc; | ||
27 | } | ||
28 | |||
29 | static void int_node__delete(struct int_node *ilist) | ||
30 | { | ||
31 | free(ilist); | ||
32 | } | ||
33 | |||
34 | static void intlist__node_delete(struct rblist *rblist __used, | ||
35 | struct rb_node *rb_node) | ||
36 | { | ||
37 | struct int_node *node = container_of(rb_node, struct int_node, rb_node); | ||
38 | |||
39 | int_node__delete(node); | ||
40 | } | ||
41 | |||
42 | static int intlist__node_cmp(struct rb_node *rb_node, const void *entry) | ||
43 | { | ||
44 | int i = (int)((long)entry); | ||
45 | struct int_node *node = container_of(rb_node, struct int_node, rb_node); | ||
46 | |||
47 | return node->i - i; | ||
48 | } | ||
49 | |||
50 | int intlist__add(struct intlist *ilist, int i) | ||
51 | { | ||
52 | return rblist__add_node(&ilist->rblist, (void *)((long)i)); | ||
53 | } | ||
54 | |||
55 | void intlist__remove(struct intlist *ilist __used, struct int_node *node) | ||
56 | { | ||
57 | int_node__delete(node); | ||
58 | } | ||
59 | |||
60 | struct int_node *intlist__find(struct intlist *ilist, int i) | ||
61 | { | ||
62 | struct int_node *node = NULL; | ||
63 | struct rb_node *rb_node = rblist__find(&ilist->rblist, (void *)((long)i)); | ||
64 | |||
65 | if (rb_node) | ||
66 | node = container_of(rb_node, struct int_node, rb_node); | ||
67 | |||
68 | return node; | ||
69 | } | ||
70 | |||
71 | struct intlist *intlist__new(void) | ||
72 | { | ||
73 | struct intlist *ilist = malloc(sizeof(*ilist)); | ||
74 | |||
75 | if (ilist != NULL) { | ||
76 | rblist__init(&ilist->rblist); | ||
77 | ilist->rblist.node_cmp = intlist__node_cmp; | ||
78 | ilist->rblist.node_new = intlist__node_new; | ||
79 | ilist->rblist.node_delete = intlist__node_delete; | ||
80 | } | ||
81 | |||
82 | return ilist; | ||
83 | } | ||
84 | |||
85 | void intlist__delete(struct intlist *ilist) | ||
86 | { | ||
87 | if (ilist != NULL) | ||
88 | rblist__delete(&ilist->rblist); | ||
89 | } | ||
90 | |||
91 | struct int_node *intlist__entry(const struct intlist *ilist, unsigned int idx) | ||
92 | { | ||
93 | struct int_node *node = NULL; | ||
94 | struct rb_node *rb_node; | ||
95 | |||
96 | rb_node = rblist__entry(&ilist->rblist, idx); | ||
97 | if (rb_node) | ||
98 | node = container_of(rb_node, struct int_node, rb_node); | ||
99 | |||
100 | return node; | ||
101 | } | ||