lib/crypto/mpi/mpi-bit.c
Source file repositories/reference/linux-study-clean/lib/crypto/mpi/mpi-bit.c
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/mpi/mpi-bit.c- Extension
.c- Size
- 4039 bytes
- Lines
- 178
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/export.hmpi-internal.hlonglong.h
Detected Declarations
function mpi_normalizefunction mpi_get_nbitsfunction mpi_test_bitfunction mpi_set_bitfunction mpi_rshiftexport mpi_get_nbitsexport mpi_test_bitexport mpi_set_bitexport mpi_rshift
Annotated Snippet
if (nlimbs >= x->nlimbs) {
x->nlimbs = 0;
return 0;
}
if (nlimbs) {
for (i = 0; i < x->nlimbs - nlimbs; i++)
x->d[i] = x->d[i+nlimbs];
x->d[i] = 0;
x->nlimbs -= nlimbs;
}
if (x->nlimbs && nbits)
mpihelp_rshift(x->d, x->d, x->nlimbs, nbits);
} else if (nlimbs) {
/* Copy and shift by more or equal bits than in a limb. */
xsize = a->nlimbs;
x->sign = a->sign;
err = RESIZE_IF_NEEDED(x, xsize);
if (err)
return err;
x->nlimbs = xsize;
for (i = 0; i < a->nlimbs; i++)
x->d[i] = a->d[i];
x->nlimbs = i;
if (nlimbs >= x->nlimbs) {
x->nlimbs = 0;
return 0;
}
for (i = 0; i < x->nlimbs - nlimbs; i++)
x->d[i] = x->d[i+nlimbs];
x->d[i] = 0;
x->nlimbs -= nlimbs;
if (x->nlimbs && nbits)
mpihelp_rshift(x->d, x->d, x->nlimbs, nbits);
} else {
/* Copy and shift by less than bits in a limb. */
xsize = a->nlimbs;
x->sign = a->sign;
err = RESIZE_IF_NEEDED(x, xsize);
if (err)
return err;
x->nlimbs = xsize;
if (xsize) {
if (nbits)
mpihelp_rshift(x->d, a->d, x->nlimbs, nbits);
else {
/* The rshift helper function is not specified for
* NBITS==0, thus we do a plain copy here.
*/
for (i = 0; i < x->nlimbs; i++)
x->d[i] = a->d[i];
}
}
}
MPN_NORMALIZE(x->d, x->nlimbs);
return 0;
}
EXPORT_SYMBOL_GPL(mpi_rshift);
Annotation
- Immediate include surface: `linux/export.h`, `mpi-internal.h`, `longlong.h`.
- Detected declarations: `function mpi_normalize`, `function mpi_get_nbits`, `function mpi_test_bit`, `function mpi_set_bit`, `function mpi_rshift`, `export mpi_get_nbits`, `export mpi_test_bit`, `export mpi_set_bit`, `export mpi_rshift`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration 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.