lib/crypto/mpi/mpi-add.c
Source file repositories/reference/linux-study-clean/lib/crypto/mpi/mpi-add.c
File Facts
- System
- Linux kernel
- Corpus path
lib/crypto/mpi/mpi-add.c- Extension
.c- Size
- 2604 bytes
- Lines
- 121
- 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.h
Detected Declarations
function mpi_addfunction mpi_subfunction mpi_addmfunction mpi_submexport mpi_addexport mpi_subexport mpi_addmexport mpi_subm
Annotated Snippet
if (usize != vsize) {
mpihelp_sub(wp, up, usize, vp, vsize);
wsize = usize;
MPN_NORMALIZE(wp, wsize);
wsign = usign;
} else if (mpihelp_cmp(up, vp, usize) < 0) {
mpihelp_sub_n(wp, vp, up, usize);
wsize = usize;
MPN_NORMALIZE(wp, wsize);
if (!usign)
wsign = 1;
} else {
mpihelp_sub_n(wp, up, vp, usize);
wsize = usize;
MPN_NORMALIZE(wp, wsize);
if (usign)
wsign = 1;
}
} else { /* U and V have same sign. Add them. */
mpi_limb_t cy = mpihelp_add(wp, up, usize, vp, vsize);
wp[usize] = cy;
wsize = usize + cy;
if (usign)
wsign = 1;
}
w->nlimbs = wsize;
w->sign = wsign;
return 0;
}
EXPORT_SYMBOL_GPL(mpi_add);
int mpi_sub(MPI w, MPI u, MPI v)
{
int err;
MPI vv;
vv = mpi_copy(v);
if (!vv)
return -ENOMEM;
vv->sign = !vv->sign;
err = mpi_add(w, u, vv);
mpi_free(vv);
return err;
}
EXPORT_SYMBOL_GPL(mpi_sub);
int mpi_addm(MPI w, MPI u, MPI v, MPI m)
{
return mpi_add(w, u, v) ?:
mpi_mod(w, w, m);
}
EXPORT_SYMBOL_GPL(mpi_addm);
int mpi_subm(MPI w, MPI u, MPI v, MPI m)
{
return mpi_sub(w, u, v) ?:
mpi_mod(w, w, m);
}
EXPORT_SYMBOL_GPL(mpi_subm);
Annotation
- Immediate include surface: `linux/export.h`, `mpi-internal.h`.
- Detected declarations: `function mpi_add`, `function mpi_sub`, `function mpi_addm`, `function mpi_subm`, `export mpi_add`, `export mpi_sub`, `export mpi_addm`, `export mpi_subm`.
- 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.