tools/lib/perf/include/internal/rc_check.h
Source file repositories/reference/linux-study-clean/tools/lib/perf/include/internal/rc_check.h
File Facts
- System
- Linux kernel
- Corpus path
tools/lib/perf/include/internal/rc_check.h- Extension
.h- Size
- 3507 bytes
- Lines
- 114
- 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
stdlib.hlinux/zalloc.h
Detected Declarations
struct struct_name
Annotated Snippet
struct struct_name { \
struct original_##struct_name *orig; \
}; \
struct original_##struct_name
/* Declare a reference counted struct variable. */
#define RC_STRUCT(struct_name) struct original_##struct_name
/*
* Interpose the indirection. Result will hold the indirection and object is the
* reference counted struct.
*/
#define ADD_RC_CHK(result, object) \
( \
object ? (result = malloc(sizeof(*result)), \
result ? (result->orig = object, result) \
: (result = NULL, NULL)) \
: (result = NULL, NULL) \
)
/* Strip the indirection layer. */
#define RC_CHK_ACCESS(object) object->orig
/* Frees the object and the indirection layer. */
#define RC_CHK_FREE(object) \
do { \
zfree(&object->orig); \
free(object); \
} while(0)
/* A get operation adding the indirection layer. */
#define RC_CHK_GET(result, object) ADD_RC_CHK(result, (object ? object->orig : NULL))
/* A put operation removing the indirection layer. */
#define RC_CHK_PUT(object) \
do { \
if (object) { \
object->orig = NULL; \
free(object); \
} \
} while(0)
/* Pointer equality when the indirection may or may not be there. */
#define RC_CHK_EQUAL(object1, object2) (object1 == object2 || \
(object1 && object2 && object1->orig == object2->orig))
#endif
#endif /* __LIBPERF_INTERNAL_RC_CHECK_H */
Annotation
- Immediate include surface: `stdlib.h`, `linux/zalloc.h`.
- Detected declarations: `struct struct_name`.
- 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.