tools/testing/selftests/powerpc/include/utils.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/include/utils.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/include/utils.h- Extension
.h- Size
- 5617 bytes
- Lines
- 212
- 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
stdint.hstdio.hstdbool.hsys/signal.hlinux/auxvec.hlinux/perf_event.hasm/cputable.hreg.hunistd.hsys/syscall.h
Detected Declarations
struct perf_event_readfunction gettidfunction have_hwcapfunction have_hwcap2function have_hwcap2
Annotated Snippet
struct perf_event_read {
__u64 nr;
__u64 l1d_misses;
};
#if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 30)
#include <sys/syscall.h>
static inline pid_t gettid(void)
{
return syscall(SYS_gettid);
}
#endif
static inline bool have_hwcap(unsigned long ftr)
{
return ((unsigned long)get_auxv_entry(AT_HWCAP) & ftr) == ftr;
}
#ifdef AT_HWCAP2
static inline bool have_hwcap2(unsigned long ftr2)
{
return ((unsigned long)get_auxv_entry(AT_HWCAP2) & ftr2) == ftr2;
}
#else
static inline bool have_hwcap2(unsigned long ftr2)
{
return false;
}
#endif
static inline char *auxv_base_platform(void)
{
return ((char *)get_auxv_entry(AT_BASE_PLATFORM));
}
static inline char *auxv_platform(void)
{
return ((char *)get_auxv_entry(AT_PLATFORM));
}
bool is_ppc64le(void);
int using_hash_mmu(bool *using_hash);
struct sigaction push_signal_handler(int sig, void (*fn)(int, siginfo_t *, void *));
struct sigaction pop_signal_handler(int sig, struct sigaction old_handler);
/* Yes, this is evil */
#define FAIL_IF(x) \
do { \
if ((x)) { \
fprintf(stderr, \
"[FAIL] Test FAILED on line %d\n", __LINE__); \
return 1; \
} \
} while (0)
#define FAIL_IF_MSG(x, msg) \
do { \
if ((x)) { \
fprintf(stderr, \
"[FAIL] Test FAILED on line %d: %s\n", \
__LINE__, msg); \
return 1; \
} \
} while (0)
#define FAIL_IF_EXIT(x) \
do { \
if ((x)) { \
fprintf(stderr, \
"[FAIL] Test FAILED on line %d\n", __LINE__); \
_exit(1); \
} \
} while (0)
#define FAIL_IF_EXIT_MSG(x, msg) \
do { \
if ((x)) { \
fprintf(stderr, \
"[FAIL] Test FAILED on line %d: %s\n", \
__LINE__, msg); \
_exit(1); \
} \
} while (0)
/* The test harness uses this, yes it's gross */
#define MAGIC_SKIP_RETURN_VALUE 99
#define SKIP_IF(x) \
Annotation
- Immediate include surface: `stdint.h`, `stdio.h`, `stdbool.h`, `sys/signal.h`, `linux/auxvec.h`, `linux/perf_event.h`, `asm/cputable.h`, `reg.h`.
- Detected declarations: `struct perf_event_read`, `function gettid`, `function have_hwcap`, `function have_hwcap2`, `function have_hwcap2`.
- 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.