perf intlist: Change 'struct intlist' int member to 'unsigned long'
This is to let intlist support addresses as its payload. One potential problem is it can't support negative number. But so far, there is no such kind of use case. Signed-off-by: Jin Yao <yao.jin@linux.intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jin Yao <yao.jin@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20210207080935.31784-1-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
a81fbb8771
commit
94253393df
|
@ -13,7 +13,7 @@
|
|||
static struct rb_node *intlist__node_new(struct rblist *rblist __maybe_unused,
|
||||
const void *entry)
|
||||
{
|
||||
int i = (int)((long)entry);
|
||||
unsigned long i = (unsigned long)entry;
|
||||
struct rb_node *rc = NULL;
|
||||
struct int_node *node = malloc(sizeof(*node));
|
||||
|
||||
|
@ -41,15 +41,20 @@ static void intlist__node_delete(struct rblist *rblist __maybe_unused,
|
|||
|
||||
static int intlist__node_cmp(struct rb_node *rb_node, const void *entry)
|
||||
{
|
||||
int i = (int)((long)entry);
|
||||
unsigned long i = (unsigned long)entry;
|
||||
struct int_node *node = container_of(rb_node, struct int_node, rb_node);
|
||||
|
||||
return node->i - i;
|
||||
if (node->i > i)
|
||||
return 1;
|
||||
else if (node->i < i)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int intlist__add(struct intlist *ilist, int i)
|
||||
int intlist__add(struct intlist *ilist, unsigned long i)
|
||||
{
|
||||
return rblist__add_node(&ilist->rblist, (void *)((long)i));
|
||||
return rblist__add_node(&ilist->rblist, (void *)i);
|
||||
}
|
||||
|
||||
void intlist__remove(struct intlist *ilist, struct int_node *node)
|
||||
|
@ -58,7 +63,7 @@ void intlist__remove(struct intlist *ilist, struct int_node *node)
|
|||
}
|
||||
|
||||
static struct int_node *__intlist__findnew(struct intlist *ilist,
|
||||
int i, bool create)
|
||||
unsigned long i, bool create)
|
||||
{
|
||||
struct int_node *node = NULL;
|
||||
struct rb_node *rb_node;
|
||||
|
@ -67,9 +72,9 @@ static struct int_node *__intlist__findnew(struct intlist *ilist,
|
|||
return NULL;
|
||||
|
||||
if (create)
|
||||
rb_node = rblist__findnew(&ilist->rblist, (void *)((long)i));
|
||||
rb_node = rblist__findnew(&ilist->rblist, (void *)i);
|
||||
else
|
||||
rb_node = rblist__find(&ilist->rblist, (void *)((long)i));
|
||||
rb_node = rblist__find(&ilist->rblist, (void *)i);
|
||||
|
||||
if (rb_node)
|
||||
node = container_of(rb_node, struct int_node, rb_node);
|
||||
|
@ -77,12 +82,12 @@ static struct int_node *__intlist__findnew(struct intlist *ilist,
|
|||
return node;
|
||||
}
|
||||
|
||||
struct int_node *intlist__find(struct intlist *ilist, int i)
|
||||
struct int_node *intlist__find(struct intlist *ilist, unsigned long i)
|
||||
{
|
||||
return __intlist__findnew(ilist, i, false);
|
||||
}
|
||||
|
||||
struct int_node *intlist__findnew(struct intlist *ilist, int i)
|
||||
struct int_node *intlist__findnew(struct intlist *ilist, unsigned long i)
|
||||
{
|
||||
return __intlist__findnew(ilist, i, true);
|
||||
}
|
||||
|
@ -93,7 +98,7 @@ static int intlist__parse_list(struct intlist *ilist, const char *s)
|
|||
int err;
|
||||
|
||||
do {
|
||||
long value = strtol(s, &sep, 10);
|
||||
unsigned long value = strtol(s, &sep, 10);
|
||||
err = -EINVAL;
|
||||
if (*sep != ',' && *sep != '\0')
|
||||
break;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
struct int_node {
|
||||
struct rb_node rb_node;
|
||||
int i;
|
||||
unsigned long i;
|
||||
void *priv;
|
||||
};
|
||||
|
||||
|
@ -21,13 +21,13 @@ struct intlist *intlist__new(const char *slist);
|
|||
void intlist__delete(struct intlist *ilist);
|
||||
|
||||
void intlist__remove(struct intlist *ilist, struct int_node *in);
|
||||
int intlist__add(struct intlist *ilist, int i);
|
||||
int intlist__add(struct intlist *ilist, unsigned long i);
|
||||
|
||||
struct int_node *intlist__entry(const struct intlist *ilist, unsigned int idx);
|
||||
struct int_node *intlist__find(struct intlist *ilist, int i);
|
||||
struct int_node *intlist__findnew(struct intlist *ilist, int i);
|
||||
struct int_node *intlist__find(struct intlist *ilist, unsigned long i);
|
||||
struct int_node *intlist__findnew(struct intlist *ilist, unsigned long i);
|
||||
|
||||
static inline bool intlist__has_entry(struct intlist *ilist, int i)
|
||||
static inline bool intlist__has_entry(struct intlist *ilist, unsigned long i)
|
||||
{
|
||||
return intlist__find(ilist, i) != NULL;
|
||||
}
|
||||
|
|
|
@ -1074,7 +1074,7 @@ static int __show_line_range(struct line_range *lr, const char *module,
|
|||
}
|
||||
|
||||
intlist__for_each_entry(ln, lr->line_list) {
|
||||
for (; ln->i > l; l++) {
|
||||
for (; ln->i > (unsigned long)l; l++) {
|
||||
ret = show_one_line(fp, l - lr->offset);
|
||||
if (ret < 0)
|
||||
goto end;
|
||||
|
|
Loading…
Reference in New Issue