tools/include/nolibc/stdlib.h
Source file repositories/reference/linux-study-clean/tools/include/nolibc/stdlib.h
File Facts
- System
- Linux kernel
- Corpus path
tools/include/nolibc/stdlib.h- Extension
.h- Size
- 13850 bytes
- Lines
- 544
- 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
nolibc.hstd.harch.htypes.hsys.hstring.hlinux/auxvec.h
Detected Declarations
struct nolibc_heapfunction absfunction labsfunction llabsfunction abortfunction __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function zerofunction __attribute__function zerofunction zerofunction __attribute__function __attribute__function __attribute__function __attribute__function zerofunction __attribute__function zerofunction zerofunction __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__
Annotated Snippet
struct nolibc_heap {
size_t len;
char user_p[] __attribute__((__aligned__));
};
/* Buffer used to store int-to-ASCII conversions. Will only be implemented if
* any of the related functions is implemented. The area is large enough to
* store "18446744073709551615" or "-9223372036854775808" and the final zero.
*/
static __attribute__((unused)) char itoa_buffer[21];
/*
* As much as possible, please keep functions alphabetically sorted.
*/
static __inline__
int abs(int j)
{
return j >= 0 ? j : -j;
}
static __inline__
long labs(long j)
{
return j >= 0 ? j : -j;
}
static __inline__
long long llabs(long long j)
{
return j >= 0 ? j : -j;
}
/* must be exported, as it's used by libgcc for various divide functions */
void abort(void);
__attribute__((weak,unused,noreturn,section(".text.nolibc_abort")))
void abort(void)
{
_sys_kill(_sys_getpid(), SIGABRT);
for (;;);
}
static __attribute__((unused))
long atol(const char *s)
{
unsigned long ret = 0;
unsigned long d;
int neg = 0;
if (*s == '-') {
neg = 1;
s++;
}
while (1) {
d = (*s++) - '0';
if (d > 9)
break;
ret *= 10;
ret += d;
}
return neg ? -ret : ret;
}
static __attribute__((unused))
int atoi(const char *s)
{
return atol(s);
}
static __attribute__((unused))
void free(void *ptr)
{
struct nolibc_heap *heap;
if (!ptr)
return;
heap = container_of(ptr, struct nolibc_heap, user_p);
munmap(heap, heap->len);
}
#ifndef NOLIBC_NO_RUNTIME
/* getenv() tries to find the environment variable named <name> in the
* environment array pointed to by global variable "environ" which must be
* declared as a char **, and must be terminated by a NULL (it is recommended
* to set this variable to the "envp" argument of main()). If the requested
* environment variable exists its value is returned otherwise NULL is
* returned.
Annotation
- Immediate include surface: `nolibc.h`, `std.h`, `arch.h`, `types.h`, `sys.h`, `string.h`, `linux/auxvec.h`.
- Detected declarations: `struct nolibc_heap`, `function abs`, `function labs`, `function llabs`, `function abort`, `function __attribute__`, `function __attribute__`, `function __attribute__`, `function __attribute__`, `function __attribute__`.
- 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.