include/linux/compiler-context-analysis.h
Source file repositories/reference/linux-study-clean/include/linux/compiler-context-analysis.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/compiler-context-analysis.h- Extension
.h- Size
- 18428 bytes
- Lines
- 483
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function context_lock_structfunction __acquire_ctx_lockfunction __release_ctx_lockfunction __context_unsafe
Annotated Snippet
* context_lock_struct(my_handle) {
* int foo;
* long bar;
* };
*
* struct some_state {
* ...
* };
* // ... declared elsewhere ...
* context_lock_struct(some_state);
*
* Note: The implementation defines several helper functions that can acquire
* and release the context lock.
*/
# define context_lock_struct(name, ...) \
struct __ctx_lock_type(name) __VA_ARGS__ name; \
static __always_inline void __acquire_ctx_lock(const struct name *var) \
__attribute__((overloadable)) __no_context_analysis __acquires_ctx_lock(var) { } \
static __always_inline void __acquire_shared_ctx_lock(const struct name *var) \
__attribute__((overloadable)) __no_context_analysis __acquires_shared_ctx_lock(var) { } \
static __always_inline bool __try_acquire_ctx_lock(const struct name *var, bool ret) \
__attribute__((overloadable)) __no_context_analysis __try_acquires_ctx_lock(1, var) \
{ return ret; } \
static __always_inline bool __try_acquire_shared_ctx_lock(const struct name *var, bool ret) \
__attribute__((overloadable)) __no_context_analysis __try_acquires_shared_ctx_lock(1, var) \
{ return ret; } \
static __always_inline void __release_ctx_lock(const struct name *var) \
__attribute__((overloadable)) __no_context_analysis __releases_ctx_lock(var) { } \
static __always_inline void __release_shared_ctx_lock(const struct name *var) \
__attribute__((overloadable)) __no_context_analysis __releases_shared_ctx_lock(var) { } \
static __always_inline void __assume_ctx_lock(const struct name *var) \
__attribute__((overloadable)) __assumes_ctx_lock(var) { } \
static __always_inline void __assume_shared_ctx_lock(const struct name *var) \
__attribute__((overloadable)) __assumes_shared_ctx_lock(var) { } \
struct name
/**
* disable_context_analysis() - disables context analysis
*
* Disables context analysis. Must be paired with a later
* enable_context_analysis().
*/
# define disable_context_analysis() \
__diag_push(); \
__diag_ignore_all("-Wunknown-warning-option", "") \
__diag_ignore_all("-Wthread-safety", "") \
__diag_ignore_all("-Wthread-safety-pointer", "")
/**
* enable_context_analysis() - re-enables context analysis
*
* Re-enables context analysis. Must be paired with a prior
* disable_context_analysis().
*/
# define enable_context_analysis() __diag_pop()
/**
* __no_context_analysis - function attribute, disables context analysis
*
* Function attribute denoting that context analysis is disabled for the
* whole function. Prefer use of `context_unsafe()` where possible.
*/
# define __no_context_analysis __attribute__((no_thread_safety_analysis))
#else /* !WARN_CONTEXT_ANALYSIS */
# define __ctx_lock_type(name)
# define __reentrant_ctx_lock
# define __acquires_ctx_lock(...)
# define __acquires_shared_ctx_lock(...)
# define __try_acquires_ctx_lock(ret, var)
# define __try_acquires_shared_ctx_lock(ret, var)
# define __releases_ctx_lock(...)
# define __releases_shared_ctx_lock(...)
# define __assumes_ctx_lock(...)
# define __assumes_shared_ctx_lock(...)
# define __returns_ctx_lock(var)
# define __guarded_by(...)
# define __pt_guarded_by(...)
# define __excludes_ctx_lock(...)
# define __requires_ctx_lock(...)
# define __requires_shared_ctx_lock(...)
# define __acquire_ctx_lock(var) do { } while (0)
# define __acquire_shared_ctx_lock(var) do { } while (0)
# define __try_acquire_ctx_lock(var, ret) (ret)
# define __try_acquire_shared_ctx_lock(var, ret) (ret)
# define __release_ctx_lock(var) do { } while (0)
# define __release_shared_ctx_lock(var) do { } while (0)
# define __assume_ctx_lock(var) do { (void)(var); } while (0)
# define __assume_shared_ctx_lock(var) do { (void)(var); } while (0)
Annotation
- Detected declarations: `function context_lock_struct`, `function __acquire_ctx_lock`, `function __release_ctx_lock`, `function __context_unsafe`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.