arch/s390/lib/string.c
Source file repositories/reference/linux-study-clean/arch/s390/lib/string.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/lib/string.c- Extension
.c- Size
- 9417 bytes
- Lines
- 486
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/types.hlinux/string.hlinux/export.hasm/facility.hasm/asm.h
Detected Declarations
function Authorfunction strlenfunction strnlenfunction strcmpfunction clclefunction memcmpexport __memmoveexport memmoveexport __memsetexport memsetexport __memcpyexport memcpyexport strlenexport strnlenexport strcatexport strncatexport strcmpexport strstrexport memchrexport memcmpexport memscan
Annotated Snippet
while (n >= 256) {
asm volatile(
" mvc 0(256,%[d]),0(%[s])\n"
:
: [d] "a" (d), [s] "a" (s)
: "memory");
d += 256;
s += 256;
n -= 256;
}
if (n) {
asm volatile(
" exrl %[n],0f\n"
" j 1f\n"
"0: mvc 0(1,%[d]),0(%[s])\n"
"1:"
:
: [d] "a" (d), [s] "a" (s), [n] "a" (n - 1)
: "memory");
}
return dest;
}
/* Backward copy */
if (test_facility(61)) {
/* Use mvcrl instruction if available */
while (n >= 256) {
asm volatile(
" lghi %%r0,255\n"
" .insn sse,0xe50a00000000,%[d],%[s]\n"
: [d] "=Q" (*(d + n - 256))
: [s] "Q" (*(s + n - 256))
: "0", "memory");
n -= 256;
}
if (n) {
asm volatile(
" lgr %%r0,%[n]\n"
" .insn sse,0xe50a00000000,%[d],%[s]\n"
: [d] "=Q" (*d)
: [s] "Q" (*s), [n] "d" (n - 1)
: "0", "memory");
}
} else {
while (n--)
d[n] = s[n];
}
return dest;
}
SYMBOL_FUNCTION_ALIAS(memmove, __memmove);
EXPORT_SYMBOL(__memmove);
EXPORT_SYMBOL(memmove);
#endif
#ifdef __HAVE_ARCH_MEMSET
noinstr void *__memset(void *s, int c, size_t n)
{
char *xs = s;
if (!n)
return s;
if (!c) {
/* Clear memory */
while (n >= 256) {
asm volatile(
" xc 0(256,%[xs]),0(%[xs])"
:
: [xs] "a" (xs)
: "cc", "memory");
xs += 256;
n -= 256;
}
if (!n)
return s;
asm volatile(
" exrl %[n],0f\n"
" j 1f\n"
"0: xc 0(1,%[xs]),0(%[xs])\n"
"1:"
:
: [xs] "a" (xs), [n] "a" (n - 1)
: "cc", "memory");
} else {
/* Fill memory */
while (n >= 256) {
*xs = c;
asm volatile(
" mvc 1(255,%[xs]),0(%[xs])"
:
: [xs] "a" (xs)
: "memory");
Annotation
- Immediate include surface: `linux/types.h`, `linux/string.h`, `linux/export.h`, `asm/facility.h`, `asm/asm.h`.
- Detected declarations: `function Author`, `function strlen`, `function strnlen`, `function strcmp`, `function clcle`, `function memcmp`, `export __memmove`, `export memmove`, `export __memset`, `export memset`.
- Atlas domain: Architecture Layer / arch/s390.
- 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.