tools/perf/util/intlist.c
Source file repositories/reference/linux-study-clean/tools/perf/util/intlist.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/intlist.c- Extension
.c- Size
- 3144 bytes
- Lines
- 151
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hstdlib.hlinux/compiler.hintlist.h
Detected Declarations
function int_node__deletefunction intlist__node_deletefunction intlist__node_cmpfunction intlist__addfunction intlist__removefunction intlist__parse_listfunction intlist__delete
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Based on intlist.c by:
* (c) 2009 Arnaldo Carvalho de Melo <acme@redhat.com>
*/
#include <errno.h>
#include <stdlib.h>
#include <linux/compiler.h>
#include "intlist.h"
static struct rb_node *intlist__node_new(struct rblist *rblist __maybe_unused,
const void *entry)
{
unsigned long i = (unsigned long)entry;
struct rb_node *rc = NULL;
struct int_node *node = malloc(sizeof(*node));
if (node != NULL) {
node->i = i;
node->priv = NULL;
rc = &node->rb_node;
}
return rc;
}
static void int_node__delete(struct int_node *ilist)
{
free(ilist);
}
static void intlist__node_delete(struct rblist *rblist __maybe_unused,
struct rb_node *rb_node)
{
struct int_node *node = container_of(rb_node, struct int_node, rb_node);
int_node__delete(node);
}
static int intlist__node_cmp(struct rb_node *rb_node, const void *entry)
{
unsigned long i = (unsigned long)entry;
struct int_node *node = container_of(rb_node, struct int_node, rb_node);
if (node->i > i)
return 1;
else if (node->i < i)
return -1;
return 0;
}
int intlist__add(struct intlist *ilist, unsigned long i)
{
return rblist__add_node(&ilist->rblist, (void *)i);
}
void intlist__remove(struct intlist *ilist, struct int_node *node)
{
rblist__remove_node(&ilist->rblist, &node->rb_node);
}
static struct int_node *__intlist__findnew(struct intlist *ilist,
unsigned long i, bool create)
{
struct int_node *node = NULL;
struct rb_node *rb_node;
if (ilist == NULL)
return NULL;
if (create)
rb_node = rblist__findnew(&ilist->rblist, (void *)i);
else
rb_node = rblist__find(&ilist->rblist, (void *)i);
if (rb_node)
node = container_of(rb_node, struct int_node, rb_node);
return node;
}
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, unsigned long i)
Annotation
- Immediate include surface: `errno.h`, `stdlib.h`, `linux/compiler.h`, `intlist.h`.
- Detected declarations: `function int_node__delete`, `function intlist__node_delete`, `function intlist__node_cmp`, `function intlist__add`, `function intlist__remove`, `function intlist__parse_list`, `function intlist__delete`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.