tools/include/nolibc/unistd.h
Source file repositories/reference/linux-study-clean/tools/include/nolibc/unistd.h
File Facts
- System
- Linux kernel
- Corpus path
tools/include/nolibc/unistd.h- Extension
.h- Size
- 2586 bytes
- Lines
- 115
- 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.h
Detected Declarations
function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__function __attribute__
Annotated Snippet
#include "nolibc.h"
#ifndef _NOLIBC_UNISTD_H
#define _NOLIBC_UNISTD_H
#include "std.h"
#include "arch.h"
#include "types.h"
#include "sys.h"
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#define F_OK 0
#define X_OK 1
#define W_OK 2
#define R_OK 4
/*
* int access(const char *path, int amode);
* int faccessat(int fd, const char *path, int amode, int flag);
*/
static __attribute__((unused))
int _sys_faccessat(int fd, const char *path, int amode, int flag)
{
return __nolibc_syscall4(__NR_faccessat, fd, path, amode, flag);
}
static __attribute__((unused))
int faccessat(int fd, const char *path, int amode, int flag)
{
return __sysret(_sys_faccessat(fd, path, amode, flag));
}
static __attribute__((unused))
int access(const char *path, int amode)
{
return faccessat(AT_FDCWD, path, amode, 0);
}
#if !defined(_sys_ftruncate64) && defined(__NR_ftruncate64)
static __attribute__((unused))
int _sys_ftruncate64(int fd, uint32_t length0, uint32_t length1)
{
return __nolibc_syscall3(__NR_ftruncate64, fd, length0, length1);
}
#define _sys_ftruncate64 _sys_ftruncate64
#endif
static __attribute__((unused))
int _sys_ftruncate(int fd, off_t length)
{
#if defined(_sys_ftruncate64)
return _sys_ftruncate64(fd, __NOLIBC_LLARGPART(length, 0), __NOLIBC_LLARGPART(length, 1));
#else
return __nolibc_syscall2(__NR_ftruncate, fd, length);
#endif
}
static __attribute__((unused))
int ftruncate(int fd, off_t length)
{
return __sysret(_sys_ftruncate(fd, length));
}
static __attribute__((unused))
int msleep(unsigned int msecs)
{
struct timeval my_timeval = { msecs / 1000, (msecs % 1000) * 1000 };
if (_sys_select(0, NULL, NULL, NULL, &my_timeval) < 0)
return (my_timeval.tv_sec * 1000) +
(my_timeval.tv_usec / 1000) +
!!(my_timeval.tv_usec % 1000);
else
return 0;
}
static __attribute__((unused))
unsigned int sleep(unsigned int seconds)
{
struct timeval my_timeval = { seconds, 0 };
if (_sys_select(0, NULL, NULL, NULL, &my_timeval) < 0)
return my_timeval.tv_sec + !!my_timeval.tv_usec;
else
return 0;
Annotation
- Immediate include surface: `nolibc.h`, `std.h`, `arch.h`, `types.h`, `sys.h`.
- Detected declarations: `function __attribute__`, `function __attribute__`, `function __attribute__`, `function __attribute__`, `function __attribute__`, `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.