lib/tests/shdi3_kunit.c
Source file repositories/reference/linux-study-clean/lib/tests/shdi3_kunit.c
File Facts
- System
- Linux kernel
- Corpus path
lib/tests/shdi3_kunit.c- Extension
.c- Size
- 6549 bytes
- Lines
- 176
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: implementation source
- Status
- source implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/module.hlinux/libgcc.hkunit/test.h
Detected Declarations
struct shdi3_test_entryfunction shdi3_test_ashldi3function shdi3_test_ashrdi3function shdi3_test_lshrdi3
Annotated Snippet
struct shdi3_test_entry {
long long input;
int shift;
long long result;
};
static const struct shdi3_test_entry ashldi3_testdata[] = {
/* https://github.com/llvm/llvm-project/compiler-rt/test/builtins/Unit/ashldi3_test.c */
{ 0x0123456789ABCDEFLL, 0, 0x123456789ABCDEFLL },
{ 0x0123456789ABCDEFLL, 1, 0x2468ACF13579BDELL },
{ 0x0123456789ABCDEFLL, 2, 0x48D159E26AF37BCLL },
{ 0x0123456789ABCDEFLL, 3, 0x91A2B3C4D5E6F78LL },
{ 0x0123456789ABCDEFLL, 4, 0x123456789ABCDEF0LL },
{ 0x0123456789ABCDEFLL, 28, 0x789ABCDEF0000000LL },
{ 0x0123456789ABCDEFLL, 29, 0xF13579BDE0000000LL },
{ 0x0123456789ABCDEFLL, 30, 0xE26AF37BC0000000LL },
{ 0x0123456789ABCDEFLL, 31, 0xC4D5E6F780000000LL },
{ 0x0123456789ABCDEFLL, 32, 0x89ABCDEF00000000LL },
{ 0x0123456789ABCDEFLL, 33, 0x13579BDE00000000LL },
{ 0x0123456789ABCDEFLL, 34, 0x26AF37BC00000000LL },
{ 0x0123456789ABCDEFLL, 35, 0x4D5E6F7800000000LL },
{ 0x0123456789ABCDEFLL, 36, 0x9ABCDEF000000000LL },
{ 0x0123456789ABCDEFLL, 60, 0xF000000000000000LL },
{ 0x0123456789ABCDEFLL, 61, 0xE000000000000000LL },
{ 0x0123456789ABCDEFLL, 62, 0xC000000000000000LL },
{ 0x0123456789ABCDEFLL, 63, 0x8000000000000000LL },
};
static void shdi3_test_ashldi3(struct kunit *test)
{
const struct shdi3_test_entry *e;
long long ret;
for (e = ashldi3_testdata;
e < ashldi3_testdata + ARRAY_SIZE(ashldi3_testdata); e++) {
ret = __ashldi3(e->input, e->shift);
KUNIT_EXPECT_EQ_MSG(test, ret, e->result,
" when evaluating __ashldi3(%lld, %d)",
e->input, e->shift);
}
}
static const struct shdi3_test_entry ashrdi3_testdata[] = {
/* https://github.com/llvm/llvm-project/compiler-rt/test/builtins/Unit/ashrdi3_test.c */
{ 0x0123456789ABCDEFLL, 0, 0x123456789ABCDEFLL },
{ 0x0123456789ABCDEFLL, 1, 0x91A2B3C4D5E6F7LL },
{ 0x0123456789ABCDEFLL, 2, 0x48D159E26AF37BLL },
{ 0x0123456789ABCDEFLL, 3, 0x2468ACF13579BDLL },
{ 0x0123456789ABCDEFLL, 4, 0x123456789ABCDELL },
{ 0x0123456789ABCDEFLL, 28, 0x12345678LL },
{ 0x0123456789ABCDEFLL, 29, 0x91A2B3CLL },
{ 0x0123456789ABCDEFLL, 30, 0x48D159ELL },
{ 0x0123456789ABCDEFLL, 31, 0x2468ACFLL },
{ 0x0123456789ABCDEFLL, 32, 0x1234567LL },
{ 0x0123456789ABCDEFLL, 33, 0x91A2B3LL },
{ 0x0123456789ABCDEFLL, 34, 0x48D159LL },
{ 0x0123456789ABCDEFLL, 35, 0x2468ACLL },
{ 0x0123456789ABCDEFLL, 36, 0x123456LL },
{ 0x0123456789ABCDEFLL, 60, 0 },
{ 0x0123456789ABCDEFLL, 61, 0 },
{ 0x0123456789ABCDEFLL, 62, 0 },
{ 0x0123456789ABCDEFLL, 63, 0 },
{ 0xFEDCBA9876543210LL, 0, 0xFEDCBA9876543210LL },
{ 0xFEDCBA9876543210LL, 1, 0xFF6E5D4C3B2A1908LL },
{ 0xFEDCBA9876543210LL, 2, 0xFFB72EA61D950C84LL },
{ 0xFEDCBA9876543210LL, 3, 0xFFDB97530ECA8642LL },
{ 0xFEDCBA9876543210LL, 4, 0xFFEDCBA987654321LL },
{ 0xFEDCBA9876543210LL, 28, 0xFFFFFFFFEDCBA987LL },
{ 0xFEDCBA9876543210LL, 29, 0xFFFFFFFFF6E5D4C3LL },
{ 0xFEDCBA9876543210LL, 30, 0xFFFFFFFFFB72EA61LL },
{ 0xFEDCBA9876543210LL, 31, 0xFFFFFFFFFDB97530LL },
{ 0xFEDCBA9876543210LL, 32, 0xFFFFFFFFFEDCBA98LL },
{ 0xFEDCBA9876543210LL, 33, 0xFFFFFFFFFF6E5D4CLL },
{ 0xFEDCBA9876543210LL, 34, 0xFFFFFFFFFFB72EA6LL },
{ 0xFEDCBA9876543210LL, 35, 0xFFFFFFFFFFDB9753LL },
{ 0xFEDCBA9876543210LL, 36, 0xFFFFFFFFFFEDCBA9LL },
{ 0xAEDCBA9876543210LL, 60, 0xFFFFFFFFFFFFFFFALL },
{ 0xAEDCBA9876543210LL, 61, 0xFFFFFFFFFFFFFFFDLL },
{ 0xAEDCBA9876543210LL, 62, 0xFFFFFFFFFFFFFFFELL },
{ 0xAEDCBA9876543210LL, 63, 0xFFFFFFFFFFFFFFFFLL },
};
static void shdi3_test_ashrdi3(struct kunit *test)
{
const struct shdi3_test_entry *e;
long long ret;
for (e = ashrdi3_testdata;
e < ashrdi3_testdata + ARRAY_SIZE(ashrdi3_testdata); e++) {
ret = __ashrdi3(e->input, e->shift);
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/module.h`, `linux/libgcc.h`, `kunit/test.h`.
- Detected declarations: `struct shdi3_test_entry`, `function shdi3_test_ashldi3`, `function shdi3_test_ashrdi3`, `function shdi3_test_lshrdi3`.
- Atlas domain: Kernel Services / lib.
- 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.