tools/testing/selftests/rseq/legacy_check.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/rseq/legacy_check.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/rseq/legacy_check.c- Extension
.c- Size
- 1069 bytes
- Lines
- 66
- 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.hsignal.hstdint.hunistd.hrseq.h../kselftest_harness.h
Detected Declarations
function sigfn
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <errno.h>
#include <signal.h>
#include <stdint.h>
#include <unistd.h>
#include "rseq.h"
#include "../kselftest_harness.h"
FIXTURE(legacy)
{
};
static int cpu_id_in_sigfn = -1;
static void sigfn(int sig)
{
struct rseq_abi *rs = rseq_get_abi();
cpu_id_in_sigfn = rs->cpu_id_start;
}
FIXTURE_SETUP(legacy)
{
int res = __rseq_register_current_thread(true, true);
switch (res) {
case -ENOSYS:
SKIP(return, "RSEQ not enabled\n");
case -EBUSY:
SKIP(return, "GLIBC owns RSEQ. Disable GLIBC RSEQ registration\n");
default:
ASSERT_EQ(res, 0);
}
ASSERT_NE(signal(SIGUSR1, sigfn), SIG_ERR);
}
FIXTURE_TEARDOWN(legacy)
{
}
TEST_F(legacy, legacy_test)
{
struct rseq_abi *rs = rseq_get_abi();
ASSERT_NE(rs, NULL);
/* Overwrite rs::cpu_id_start */
rs->cpu_id_start = -1;
sleep(1);
ASSERT_NE(rs->cpu_id_start, -1);
rs->cpu_id_start = -1;
ASSERT_EQ(raise(SIGUSR1), 0);
ASSERT_NE(rs->cpu_id_start, -1);
ASSERT_NE(cpu_id_in_sigfn, -1);
}
TEST_HARNESS_MAIN
Annotation
- Immediate include surface: `errno.h`, `signal.h`, `stdint.h`, `unistd.h`, `rseq.h`, `../kselftest_harness.h`.
- Detected declarations: `function sigfn`.
- 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.