BuildSystem: Move all userpace libraries under the userspace directory
As the number of libraries is increasing, root directory starts to expand. This adds better organization for libraries
This commit is contained in:
33
userspace/libraries/CMakeLists.txt
Normal file
33
userspace/libraries/CMakeLists.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
|
||||
project(libraries CXX)
|
||||
|
||||
set(USERSPACE_LIBRARIES
|
||||
LibC
|
||||
LibELF
|
||||
LibFont
|
||||
LibGUI
|
||||
LibImage
|
||||
LibInput
|
||||
)
|
||||
|
||||
foreach(LIBRARY ${USERSPACE_LIBRARIES})
|
||||
add_subdirectory(${LIBRARY})
|
||||
endforeach()
|
||||
|
||||
add_custom_target(libraries)
|
||||
add_custom_target(libraries-headers)
|
||||
add_custom_target(libraries-install)
|
||||
|
||||
foreach(LIBRARY ${USERSPACE_LIBRARIES})
|
||||
string(TOLOWER ${LIBRARY} LIBRARY_LOWER)
|
||||
|
||||
if (TARGET ${LIBRARY_LOWER})
|
||||
add_dependencies(libraries ${LIBRARY_LOWER})
|
||||
# This is to allow cmake to link when libc updates
|
||||
target_link_options(${LIBRARY_LOWER} PRIVATE -nolibc)
|
||||
endif()
|
||||
|
||||
add_dependencies(libraries-headers ${LIBRARY_LOWER}-headers)
|
||||
add_dependencies(libraries-install ${LIBRARY_LOWER}-install)
|
||||
endforeach()
|
||||
68
userspace/libraries/LibC/CMakeLists.txt
Normal file
68
userspace/libraries/LibC/CMakeLists.txt
Normal file
@@ -0,0 +1,68 @@
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
|
||||
project(libc CXX ASM)
|
||||
|
||||
set(LIBC_SOURCES
|
||||
arpa/inet.cpp
|
||||
assert.cpp
|
||||
ctype.cpp
|
||||
dirent.cpp
|
||||
fcntl.cpp
|
||||
grp.cpp
|
||||
malloc.cpp
|
||||
netdb.cpp
|
||||
printf_impl.cpp
|
||||
pwd.cpp
|
||||
scanf_impl.cpp
|
||||
signal.cpp
|
||||
stdio.cpp
|
||||
stdlib.cpp
|
||||
string.cpp
|
||||
strings.cpp
|
||||
stropts.cpp
|
||||
sys/banan-os.cpp
|
||||
sys/mman.cpp
|
||||
sys/select.cpp
|
||||
sys/socket.cpp
|
||||
sys/stat.cpp
|
||||
sys/wait.cpp
|
||||
termios.cpp
|
||||
time.cpp
|
||||
unistd.cpp
|
||||
math.cpp
|
||||
icxxabi.cpp
|
||||
|
||||
../../../BAN/BAN/Assert.cpp
|
||||
)
|
||||
|
||||
add_custom_target(libc-headers
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${BANAN_INCLUDE}/
|
||||
DEPENDS sysroot
|
||||
)
|
||||
|
||||
add_custom_target(crtx
|
||||
COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crt0.S -o crt0.o
|
||||
COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crti.S -o crti.o
|
||||
COMMAND ${CMAKE_C_COMPILER} -c ${CMAKE_CURRENT_SOURCE_DIR}/arch/${BANAN_ARCH}/crtn.S -o crtn.o
|
||||
)
|
||||
|
||||
add_custom_target(crtx-install
|
||||
COMMAND ${CMAKE_COMMAND} -E copy crt0.o ${BANAN_LIB}/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy crti.o ${BANAN_LIB}/
|
||||
COMMAND ${CMAKE_COMMAND} -E copy crtn.o ${BANAN_LIB}/
|
||||
DEPENDS crtx
|
||||
)
|
||||
|
||||
add_library(libc ${LIBC_SOURCES})
|
||||
add_dependencies(libc headers crtx-install)
|
||||
|
||||
target_compile_options(libc PRIVATE -O2 -g -Wstack-usage=512 -fno-tree-loop-distribute-patterns)
|
||||
target_compile_options(libc PUBLIC -Wall -Wextra -Werror -Wno-error=stack-usage=)
|
||||
|
||||
add_custom_target(libc-install
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/libc.a ${BANAN_LIB}/
|
||||
DEPENDS libc
|
||||
BYPRODUCTS ${BANAN_LIB}/libc.a
|
||||
)
|
||||
|
||||
set(CMAKE_STATIC_LIBRARY_PREFIX "")
|
||||
34
userspace/libraries/LibC/arch/i686/crt0.S
Normal file
34
userspace/libraries/LibC/arch/i686/crt0.S
Normal file
@@ -0,0 +1,34 @@
|
||||
.section .text
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
pushl $0
|
||||
pushl %edi
|
||||
pushl %esi
|
||||
pushl %edx
|
||||
|
||||
# STACK LAYOUT
|
||||
# null
|
||||
# argc
|
||||
# argv
|
||||
# envp
|
||||
|
||||
xorl %ebp, %ebp
|
||||
|
||||
# init libc (envp already as argument)
|
||||
call _init_libc
|
||||
|
||||
# call global constructors
|
||||
call _init
|
||||
|
||||
# call main
|
||||
movl 0(%esp), %eax
|
||||
xchgl %eax, 8(%esp)
|
||||
movl %eax, (%esp)
|
||||
call main
|
||||
|
||||
subl $12, %esp
|
||||
pushl %eax
|
||||
call exit
|
||||
|
||||
.size _start, . - _start
|
||||
16
userspace/libraries/LibC/arch/i686/crti.S
Normal file
16
userspace/libraries/LibC/arch/i686/crti.S
Normal file
@@ -0,0 +1,16 @@
|
||||
/* i686 crti.s */
|
||||
.section .init
|
||||
.global _init
|
||||
.type _init, @function
|
||||
_init:
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
/* gcc will nicely put the contents of crtbegin.o's .init section here. */
|
||||
|
||||
.section .fini
|
||||
.global _fini
|
||||
.type _fini, @function
|
||||
_fini:
|
||||
pushl %ebp
|
||||
movl %esp, %ebp
|
||||
/* gcc will nicely put the contents of crtbegin.o's .fini section here. */
|
||||
10
userspace/libraries/LibC/arch/i686/crtn.S
Normal file
10
userspace/libraries/LibC/arch/i686/crtn.S
Normal file
@@ -0,0 +1,10 @@
|
||||
/* i686 crtn.s */
|
||||
.section .init
|
||||
/* gcc will nicely put the contents of crtend.o's .init section here. */
|
||||
popl %ebp
|
||||
ret
|
||||
|
||||
.section .fini
|
||||
/* gcc will nicely put the contents of crtend.o's .fini section here. */
|
||||
popl %ebp
|
||||
ret
|
||||
35
userspace/libraries/LibC/arch/x86_64/crt0.S
Normal file
35
userspace/libraries/LibC/arch/x86_64/crt0.S
Normal file
@@ -0,0 +1,35 @@
|
||||
.section .text
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
pushq $0
|
||||
pushq %rdi
|
||||
pushq %rsi
|
||||
pushq %rdx
|
||||
|
||||
# STACK LAYOUT
|
||||
# null
|
||||
# argc
|
||||
# argv
|
||||
# envp
|
||||
|
||||
xorq %rbp, %rbp
|
||||
|
||||
# init libc
|
||||
movq 0(%rsp), %rdi
|
||||
call _init_libc
|
||||
|
||||
# call global constructors
|
||||
call _init
|
||||
|
||||
# call main
|
||||
movq 16(%rsp), %rdi
|
||||
movq 8(%rsp), %rsi
|
||||
movq 0(%rsp), %rdx
|
||||
call main
|
||||
|
||||
# call exit
|
||||
movq %rax, %rdi
|
||||
call exit
|
||||
|
||||
.size _start, . - _start
|
||||
16
userspace/libraries/LibC/arch/x86_64/crti.S
Normal file
16
userspace/libraries/LibC/arch/x86_64/crti.S
Normal file
@@ -0,0 +1,16 @@
|
||||
/* x86-64 crti.s */
|
||||
.section .init
|
||||
.global _init
|
||||
.type _init, @function
|
||||
_init:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
/* gcc will nicely put the contents of crtbegin.o's .init section here. */
|
||||
|
||||
.section .fini
|
||||
.global _fini
|
||||
.type _fini, @function
|
||||
_fini:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp
|
||||
/* gcc will nicely put the contents of crtbegin.o's .fini section here. */
|
||||
10
userspace/libraries/LibC/arch/x86_64/crtn.S
Normal file
10
userspace/libraries/LibC/arch/x86_64/crtn.S
Normal file
@@ -0,0 +1,10 @@
|
||||
/* x86-64 crtn.s */
|
||||
.section .init
|
||||
/* gcc will nicely put the contents of crtend.o's .init section here. */
|
||||
popq %rbp
|
||||
ret
|
||||
|
||||
.section .fini
|
||||
/* gcc will nicely put the contents of crtend.o's .fini section here. */
|
||||
popq %rbp
|
||||
ret
|
||||
75
userspace/libraries/LibC/arpa/inet.cpp
Normal file
75
userspace/libraries/LibC/arpa/inet.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
#include <BAN/Endianness.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
uint32_t htonl(uint32_t hostlong)
|
||||
{
|
||||
return BAN::host_to_network_endian(hostlong);
|
||||
}
|
||||
|
||||
uint16_t htons(uint16_t hostshort)
|
||||
{
|
||||
return BAN::host_to_network_endian(hostshort);
|
||||
}
|
||||
|
||||
uint32_t ntohl(uint32_t netlong)
|
||||
{
|
||||
return BAN::host_to_network_endian(netlong);
|
||||
}
|
||||
|
||||
uint16_t ntohs(uint16_t netshort)
|
||||
{
|
||||
return BAN::host_to_network_endian(netshort);
|
||||
}
|
||||
|
||||
in_addr_t inet_addr(const char* cp)
|
||||
{
|
||||
uint32_t a = 0, b = 0, c = 0, d = 0;
|
||||
int ret = sscanf(cp, "%u.%u.%u.%u", &a, &b, &c, &d);
|
||||
if (ret < 1 || ret > 4)
|
||||
return (in_addr_t)(-1);
|
||||
uint32_t result = 0;
|
||||
result |= (ret == 1) ? a : a << 24;
|
||||
result |= (ret == 2) ? b : b << 16;
|
||||
result |= (ret == 3) ? c : c << 8;
|
||||
result |= (ret == 4) ? d : d << 0;
|
||||
return htonl(result);
|
||||
}
|
||||
|
||||
char* inet_ntoa(struct in_addr in)
|
||||
{
|
||||
static char buffer[16];
|
||||
uint32_t he = ntohl(in.s_addr);
|
||||
sprintf(buffer, "%u.%u.%u.%u",
|
||||
(he >> 24) & 0xFF,
|
||||
(he >> 16) & 0xFF,
|
||||
(he >> 8) & 0xFF,
|
||||
(he >> 0) & 0xFF
|
||||
);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const char* inet_ntop(int af, const void* __restrict src, char* __restrict dst, socklen_t size)
|
||||
{
|
||||
if (af == AF_INET)
|
||||
{
|
||||
if (size < INET_ADDRSTRLEN)
|
||||
{
|
||||
errno = ENOSPC;
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t he = ntohl(reinterpret_cast<const in_addr*>(src)->s_addr);
|
||||
sprintf(dst, "%u.%u.%u.%u",
|
||||
(he >> 24) & 0xFF,
|
||||
(he >> 16) & 0xFF,
|
||||
(he >> 8) & 0xFF,
|
||||
(he >> 0) & 0xFF
|
||||
);
|
||||
return dst;
|
||||
}
|
||||
|
||||
errno = EAFNOSUPPORT;
|
||||
return nullptr;
|
||||
}
|
||||
9
userspace/libraries/LibC/assert.cpp
Normal file
9
userspace/libraries/LibC/assert.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void __assert_fail(const char* expr, const char* file, int line, const char* func)
|
||||
{
|
||||
fprintf(stderr, "assert: %s:%d: %s: Assertion '%s' failed.\n", file, line, func, expr);
|
||||
abort();
|
||||
}
|
||||
80
userspace/libraries/LibC/ctype.cpp
Normal file
80
userspace/libraries/LibC/ctype.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
#include <ctype.h>
|
||||
|
||||
int isalnum(int c)
|
||||
{
|
||||
return isdigit(c) || isalpha(c);
|
||||
}
|
||||
|
||||
int isalpha(int c)
|
||||
{
|
||||
return islower(c) || isupper(c);
|
||||
}
|
||||
|
||||
int isascii(int c)
|
||||
{
|
||||
return c <= 0x7F;
|
||||
}
|
||||
|
||||
int isblank(int c)
|
||||
{
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
|
||||
int iscntrl(int c)
|
||||
{
|
||||
return c < 32 || c == 0x7F;
|
||||
}
|
||||
|
||||
int isdigit(int c)
|
||||
{
|
||||
return '0' <= c && c <= '9';
|
||||
}
|
||||
|
||||
int isgraph(int c)
|
||||
{
|
||||
return 0x21 <= c && c <= 0x7E;
|
||||
}
|
||||
|
||||
int islower(int c)
|
||||
{
|
||||
return 'a' <= c && c <= 'z';
|
||||
}
|
||||
|
||||
int isprint(int c)
|
||||
{
|
||||
return isgraph(c) || c == ' ';
|
||||
}
|
||||
|
||||
int ispunct(int c)
|
||||
{
|
||||
return isgraph(c) && !isalnum(c);
|
||||
}
|
||||
|
||||
int isspace(int c)
|
||||
{
|
||||
return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
|
||||
}
|
||||
|
||||
int isupper(int c)
|
||||
{
|
||||
return 'A' <= c && c <= 'Z';
|
||||
}
|
||||
|
||||
int isxdigit(int c)
|
||||
{
|
||||
return isdigit(c) || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F');
|
||||
}
|
||||
|
||||
int toupper(int c)
|
||||
{
|
||||
if (!islower(c))
|
||||
return c;
|
||||
return 'A' + (c - 'a');
|
||||
}
|
||||
|
||||
int tolower(int c)
|
||||
{
|
||||
if (!isupper(c))
|
||||
return c;
|
||||
return 'a' + (c - 'A');
|
||||
}
|
||||
84
userspace/libraries/LibC/dirent.cpp
Normal file
84
userspace/libraries/LibC/dirent.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct __DIR
|
||||
{
|
||||
int fd { -1 };
|
||||
size_t entry_count { 0 };
|
||||
size_t entry_index { 0 };
|
||||
// FIXME: we should probably allocate entries dynamically
|
||||
// based if syscall returns ENOBUFS
|
||||
dirent entries[128];
|
||||
};
|
||||
|
||||
int closedir(DIR* dirp)
|
||||
{
|
||||
if (dirp == nullptr || dirp->fd == -1)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
|
||||
close(dirp->fd);
|
||||
free(dirp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dirfd(DIR* dirp)
|
||||
{
|
||||
if (dirp == nullptr || dirp->fd == -1)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return dirp->fd;
|
||||
}
|
||||
|
||||
DIR* fdopendir(int fd)
|
||||
{
|
||||
DIR* dirp = (DIR*)malloc(sizeof(DIR));
|
||||
if (dirp == nullptr)
|
||||
return nullptr;
|
||||
|
||||
dirp->fd = fd;
|
||||
dirp->entry_count = 0;
|
||||
dirp->entry_index = 0;
|
||||
|
||||
return dirp;
|
||||
}
|
||||
|
||||
DIR* opendir(const char* dirname)
|
||||
{
|
||||
int fd = open(dirname, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return nullptr;
|
||||
return fdopendir(fd);
|
||||
}
|
||||
|
||||
struct dirent* readdir(DIR* dirp)
|
||||
{
|
||||
if (dirp == nullptr || dirp->fd == -1)
|
||||
{
|
||||
errno = EBADF;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dirp->entry_index++;
|
||||
if (dirp->entry_index < dirp->entry_count)
|
||||
return &dirp->entries[dirp->entry_index];
|
||||
|
||||
long entry_count = syscall(SYS_READ_DIR, dirp->fd, dirp->entries, sizeof(dirp->entries) / sizeof(dirp->entries[0]));
|
||||
if (entry_count <= 0)
|
||||
return nullptr;
|
||||
|
||||
dirp->entry_count = entry_count;
|
||||
dirp->entry_index = 0;
|
||||
|
||||
return &dirp->entries[0];
|
||||
}
|
||||
40
userspace/libraries/LibC/fcntl.cpp
Normal file
40
userspace/libraries/LibC/fcntl.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int creat(const char* path, mode_t mode)
|
||||
{
|
||||
return syscall(SYS_CREATE, path, S_IFREG | mode);
|
||||
}
|
||||
|
||||
int open(const char* path, int oflag, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, oflag);
|
||||
mode_t mode = va_arg(args, mode_t);
|
||||
va_end(args);
|
||||
|
||||
return syscall(SYS_OPEN, path, oflag, mode);
|
||||
}
|
||||
|
||||
int openat(int fd, const char* path, int oflag, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, oflag);
|
||||
mode_t mode = va_arg(args, mode_t);
|
||||
va_end(args);
|
||||
|
||||
return syscall(SYS_OPENAT, fd, path, oflag, mode);
|
||||
}
|
||||
|
||||
int fcntl(int fildes, int cmd, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, cmd);
|
||||
int extra = va_arg(args, int);
|
||||
va_end(args);
|
||||
|
||||
return syscall(SYS_FCNTL, fildes, cmd, extra);
|
||||
}
|
||||
162
userspace/libraries/LibC/grp.cpp
Normal file
162
userspace/libraries/LibC/grp.cpp
Normal file
@@ -0,0 +1,162 @@
|
||||
#include <BAN/StringView.h>
|
||||
#include <BAN/Vector.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static struct stat s_group_st;
|
||||
static char* s_group_mmap = nullptr;
|
||||
static int s_group_fd = -1;
|
||||
|
||||
static struct group s_group;
|
||||
|
||||
id_t parse_id(BAN::StringView string)
|
||||
{
|
||||
id_t id = 0;
|
||||
for (char c : string)
|
||||
{
|
||||
if (!isdigit(c))
|
||||
return -1;
|
||||
id = (id * 10) + (c - '0');
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
static bool open_group_file()
|
||||
{
|
||||
if (s_group_fd == -1)
|
||||
s_group_fd = open("/etc/group", O_RDONLY);
|
||||
if (s_group_fd == -1)
|
||||
return false;
|
||||
|
||||
if (fstat(s_group_fd, &s_group_st) == -1)
|
||||
return false;
|
||||
|
||||
if (s_group_mmap == nullptr || s_group_mmap == MAP_FAILED)
|
||||
s_group_mmap = (char*)mmap(nullptr, s_group_st.st_size, PROT_READ, MAP_PRIVATE, s_group_fd, 0);
|
||||
if (s_group_mmap == MAP_FAILED)
|
||||
return false;
|
||||
|
||||
s_group.gr_name = nullptr;
|
||||
s_group.gr_mem = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct group* fill_group(const BAN::Vector<BAN::StringView>& parts)
|
||||
{
|
||||
if (parts.size() != 4)
|
||||
return nullptr;
|
||||
|
||||
if (s_group.gr_name)
|
||||
{
|
||||
free(s_group.gr_name);
|
||||
s_group.gr_name = nullptr;
|
||||
}
|
||||
|
||||
if (s_group.gr_mem)
|
||||
{
|
||||
for (size_t i = 0; s_group.gr_mem && s_group.gr_mem[i]; i++)
|
||||
free(s_group.gr_mem[i]);
|
||||
free(s_group.gr_mem);
|
||||
s_group.gr_mem = nullptr;
|
||||
}
|
||||
|
||||
auto groups_or_error = parts[3].split(',');
|
||||
if (groups_or_error.is_error())
|
||||
return nullptr;
|
||||
auto groups = groups_or_error.release_value();
|
||||
|
||||
s_group.gr_gid = parse_id(parts[2]);
|
||||
if (s_group.gr_gid == -1)
|
||||
return nullptr;
|
||||
|
||||
s_group.gr_name = (char*)malloc(parts[0].size() + 1);
|
||||
if (s_group.gr_name == nullptr)
|
||||
return nullptr;
|
||||
memcpy(s_group.gr_name, parts[0].data(), parts[0].size());
|
||||
s_group.gr_name[parts[0].size()] = '\0';
|
||||
|
||||
s_group.gr_mem = (char**)malloc((groups.size() + 1) * sizeof(char*));
|
||||
if (s_group.gr_mem == nullptr)
|
||||
return nullptr;
|
||||
|
||||
for (size_t i = 0; i < groups.size(); i++)
|
||||
{
|
||||
s_group.gr_mem[i] = (char*)malloc(groups[i].size() + 1);
|
||||
if (s_group.gr_mem[i] == nullptr)
|
||||
{
|
||||
for (size_t j = 0; j < i; j++)
|
||||
free(s_group.gr_mem[j]);
|
||||
free(s_group.gr_mem);
|
||||
s_group.gr_mem = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
memcpy(s_group.gr_mem[i], groups[i].data(), groups[i].size());
|
||||
s_group.gr_mem[i][groups[i].size()] = '\0';
|
||||
}
|
||||
s_group.gr_mem[groups.size()] = nullptr;
|
||||
|
||||
return &s_group;
|
||||
}
|
||||
|
||||
struct group* getgrnam(const char* name)
|
||||
{
|
||||
if (s_group_mmap == nullptr || s_group_mmap == MAP_FAILED)
|
||||
if (!open_group_file())
|
||||
return nullptr;
|
||||
|
||||
off_t start = 0;
|
||||
off_t end = 0;
|
||||
while (start < s_group_st.st_size)
|
||||
{
|
||||
while (end < s_group_st.st_size && s_group_mmap[end] != '\n')
|
||||
end++;
|
||||
|
||||
BAN::StringView line(s_group_mmap + start, end - start);
|
||||
start = ++end;
|
||||
|
||||
auto parts_or_error = line.split(':', true);
|
||||
if (parts_or_error.is_error())
|
||||
return nullptr;
|
||||
|
||||
auto parts = parts_or_error.release_value();
|
||||
if (parts.size() == 4 && parts[0] == name)
|
||||
return fill_group(parts);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct group* getgrgid(gid_t gid)
|
||||
{
|
||||
if (s_group_mmap == nullptr || s_group_mmap == MAP_FAILED)
|
||||
if (!open_group_file())
|
||||
return nullptr;
|
||||
|
||||
off_t start = 0;
|
||||
off_t end = 0;
|
||||
while (start < s_group_st.st_size)
|
||||
{
|
||||
while (end < s_group_st.st_size && s_group_mmap[end] != '\n')
|
||||
end++;
|
||||
|
||||
BAN::StringView line(s_group_mmap + start, end - start);
|
||||
start = ++end;
|
||||
|
||||
auto parts_or_error = line.split(':', true);
|
||||
if (parts_or_error.is_error())
|
||||
return nullptr;
|
||||
|
||||
auto parts = parts_or_error.release_value();
|
||||
if (parts.size() == 4 && parse_id(parts[2]) == gid)
|
||||
return fill_group(parts);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
41
userspace/libraries/LibC/icxxabi.cpp
Normal file
41
userspace/libraries/LibC/icxxabi.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <BAN/Assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define ATEXIT_MAX_FUNCS 128
|
||||
|
||||
struct atexit_func_entry_t
|
||||
{
|
||||
void(*func)(void*);
|
||||
void* arg;
|
||||
void* dso_handle;
|
||||
};
|
||||
|
||||
static atexit_func_entry_t __atexit_funcs[ATEXIT_MAX_FUNCS];
|
||||
static size_t __atexit_func_count = 0;
|
||||
|
||||
extern "C" int __cxa_atexit(void(*func)(void*), void* arg, void* dso_handle)
|
||||
{
|
||||
if (__atexit_func_count >= ATEXIT_MAX_FUNCS)
|
||||
return -1;
|
||||
auto& atexit_func = __atexit_funcs[__atexit_func_count++];
|
||||
atexit_func.func = func;
|
||||
atexit_func.arg = arg;
|
||||
atexit_func.dso_handle = dso_handle;
|
||||
return 0;
|
||||
};
|
||||
|
||||
extern "C" void __cxa_finalize(void* f)
|
||||
{
|
||||
for (size_t i = __atexit_func_count; i > 0; i--)
|
||||
{
|
||||
auto& atexit_func = __atexit_funcs[i - 1];
|
||||
if (atexit_func.func == nullptr)
|
||||
continue;
|
||||
if (f == nullptr || f == atexit_func.func)
|
||||
{
|
||||
atexit_func.func(atexit_func.arg);
|
||||
atexit_func.func = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
51
userspace/libraries/LibC/include/aio.h
Normal file
51
userspace/libraries/LibC/include/aio.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef _AIO_H
|
||||
#define _AIO_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/aio.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define __need_off_t
|
||||
#define __need_pthread_attr_t
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct aiocb
|
||||
{
|
||||
int aio_fildes; /* File descriptor. */
|
||||
off_t aio_offset; /* File offset. */
|
||||
volatile void* aio_buf; /* Location of buffer. */
|
||||
size_t aio_nbytes; /* Length of transfer. */
|
||||
int aio_reqprio; /* Request priority offset. */
|
||||
struct sigevent aio_sigevent; /* Signal number and value. */
|
||||
int aio_lio_opcode; /* Operation to be performed. */
|
||||
};
|
||||
|
||||
#define AIO_ALLDONE 1
|
||||
#define AIO_CANCELLED 2
|
||||
#define AIO_NOTCANCELLED 3
|
||||
#define LIO_NOP 4
|
||||
#define LIO_NOWAIT 5
|
||||
#define LIO_READ 6
|
||||
#define LIO_WAIT 7
|
||||
#define LIO_WRITE 8
|
||||
|
||||
int aio_cancel(int fildes, struct aiocb* aiocbp);
|
||||
int aio_error(const struct aiocb* aiocbp);
|
||||
int aio_fsync(int op, struct aiocb* aiocbp);
|
||||
int aio_read(struct aiocb* aiocbp);
|
||||
ssize_t aio_return(struct aiocb* aiocbp);
|
||||
int aio_suspend(const struct aiocb* const list[], int nent, const struct timespec* timeout);
|
||||
int aio_write(struct aiocb* aiocbp);
|
||||
int lio_listio(int mode, struct aiocb* __restrict const list[__restrict], int nent, struct sigevent* __restrict sig);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
25
userspace/libraries/LibC/include/arpa/inet.h
Normal file
25
userspace/libraries/LibC/include/arpa/inet.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _INET_H
|
||||
#define _INET_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/arpa_inet.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
uint32_t htonl(uint32_t);
|
||||
uint16_t htons(uint16_t);
|
||||
uint32_t ntohl(uint32_t);
|
||||
uint16_t ntohs(uint16_t);
|
||||
|
||||
in_addr_t inet_addr(const char* cp);
|
||||
char* inet_ntoa(struct in_addr in);
|
||||
const char* inet_ntop(int af, const void* __restrict src, char* __restrict dst, socklen_t size);
|
||||
int inet_pton(int af, const char* __restrict src, void* __restrict dst);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
20
userspace/libraries/LibC/include/assert.h
Normal file
20
userspace/libraries/LibC/include/assert.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef __ASSERT_H
|
||||
#define _ASSERT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/assert.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assert(ignore) ((void)0)
|
||||
#else
|
||||
#define assert(expr) ((expr) ? (void)0 : __assert_fail(#expr, __FILE__, __LINE__, __func__))
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
[[noreturn]] void __assert_fail(const char*, const char*, int, const char*);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
15
userspace/libraries/LibC/include/bits/printf.h
Normal file
15
userspace/libraries/LibC/include/bits/printf.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef _BITS_PRINTF_H
|
||||
#define _BITS_PRINTF_H 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
int printf_impl(const char* format, va_list arguments, int (*putc_fun)(int, void*), void* data);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
85
userspace/libraries/LibC/include/bits/pthread_types.h
Normal file
85
userspace/libraries/LibC/include/bits/pthread_types.h
Normal file
@@ -0,0 +1,85 @@
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if !defined(__pthread_attr_t_defined) && (defined(__need_all_types) || defined(__need_pthread_attr_t))
|
||||
#define __pthread_attr_t_defined 1
|
||||
typedef int pthread_attr_t;
|
||||
#endif
|
||||
#undef __need_pthread_attr_t
|
||||
|
||||
#if !defined(__pthread_barrier_t_defined) && (defined(__need_all_types) || defined(__need_pthread_barrier_t))
|
||||
#define __pthread_barrier_t_defined 1
|
||||
typedef int pthread_barrier_t;
|
||||
#endif
|
||||
#undef __need_pthread_barrier_t
|
||||
|
||||
#if !defined(__pthread_barrierattr_t_defined) && (defined(__need_all_types) || defined(__need_pthread_barrierattr_t))
|
||||
#define __pthread_barrierattr_t_defined 1
|
||||
typedef int pthread_barrierattr_t;
|
||||
#endif
|
||||
#undef __need_pthread_barrierattr_t
|
||||
|
||||
#if !defined(__pthread_cond_t_defined) && (defined(__need_all_types) || defined(__need_pthread_cond_t))
|
||||
#define __pthread_cond_t_defined 1
|
||||
typedef int pthread_cond_t;
|
||||
#endif
|
||||
#undef __need_pthread_cond_t
|
||||
|
||||
#if !defined(__pthread_condattr_t_defined) && (defined(__need_all_types) || defined(__need_pthread_condattr_t))
|
||||
#define __pthread_condattr_t_defined 1
|
||||
typedef int pthread_condattr_t;
|
||||
#endif
|
||||
#undef __need_pthread_condattr_t
|
||||
|
||||
#if !defined(__pthread_key_t_defined) && (defined(__need_all_types) || defined(__need_pthread_key_t))
|
||||
#define __pthread_key_t_defined 1
|
||||
typedef int pthread_key_t;
|
||||
#endif
|
||||
#undef __need_pthread_key_t
|
||||
|
||||
#if !defined(__pthread_mutex_t_defined) && (defined(__need_all_types) || defined(__need_pthread_mutex_t))
|
||||
#define __pthread_mutex_t_defined 1
|
||||
typedef int pthread_mutex_t;
|
||||
#endif
|
||||
#undef __need_pthread_mutex_t
|
||||
|
||||
#if !defined(__pthread_mutexattr_t_defined) && (defined(__need_all_types) || defined(__need_pthread_mutexattr_t))
|
||||
#define __pthread_mutexattr_t_defined 1
|
||||
typedef int pthread_mutexattr_t;
|
||||
#endif
|
||||
#undef __need_pthread_mutexattr_t
|
||||
|
||||
#if !defined(__pthread_once_t_defined) && (defined(__need_all_types) || defined(__need_pthread_once_t))
|
||||
#define __pthread_once_t_defined 1
|
||||
typedef int pthread_once_t;
|
||||
#endif
|
||||
#undef __need_pthread_once_t
|
||||
|
||||
#if !defined(__pthread_rwlock_t_defined) && (defined(__need_all_types) || defined(__need_pthread_rwlock_t))
|
||||
#define __pthread_rwlock_t_defined 1
|
||||
typedef int pthread_rwlock_t;
|
||||
#endif
|
||||
#undef __need_pthread_rwlock_t
|
||||
|
||||
#if !defined(__pthread_rwlockattr_t_defined) && (defined(__need_all_types) || defined(__need_pthread_rwlockattr_t))
|
||||
#define __pthread_rwlockattr_t_defined 1
|
||||
typedef int pthread_rwlockattr_t;
|
||||
#endif
|
||||
#undef __need_pthread_rwlockattr_t
|
||||
|
||||
#if !defined(__pthread_spinlock_t_defined) && (defined(__need_all_types) || defined(__need_pthread_spinlock_t))
|
||||
#define __pthread_spinlock_t_defined 1
|
||||
typedef int pthread_spinlock_t;
|
||||
#endif
|
||||
#undef __need_pthread_spinlock_t
|
||||
|
||||
#if !defined(__pthread_t_defined) && (defined(__need_all_types) || defined(__need_pthread_t))
|
||||
#define __pthread_t_defined 1
|
||||
typedef int pthread_t;
|
||||
#endif
|
||||
#undef __need_pthread_t
|
||||
|
||||
__END_DECLS
|
||||
18
userspace/libraries/LibC/include/bits/types/FILE.h
Normal file
18
userspace/libraries/LibC/include/bits/types/FILE.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _BITS_TYPES_FILE_H
|
||||
#define _BITS_TYPES_FILE_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#ifndef __FILE_defined
|
||||
#define __FILE_defined 1
|
||||
struct FILE;
|
||||
typedef struct FILE FILE;
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
17
userspace/libraries/LibC/include/bits/types/locale_t.h
Normal file
17
userspace/libraries/LibC/include/bits/types/locale_t.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef _BITS_LOCALE_T_H
|
||||
#define _BITS_LOCALE_T_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/locale.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#ifndef __locale_t_defined
|
||||
#define __locale_t_defined 1
|
||||
typedef int locale_t;
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
17
userspace/libraries/LibC/include/bits/types/sa_family_t.h
Normal file
17
userspace/libraries/LibC/include/bits/types/sa_family_t.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef _BITS_TYPES_SA_FAMILY_T_H
|
||||
#define _BITS_TYPES_SA_FAMILY_T_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_select.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#ifndef __sa_family_t_defined
|
||||
#define __sa_family_t_defined 1
|
||||
typedef unsigned int sa_family_t;
|
||||
#endif
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
20
userspace/libraries/LibC/include/bits/types/timeval.h
Normal file
20
userspace/libraries/LibC/include/bits/types/timeval.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _BITS_TIMEVAL_H
|
||||
#define _BITS_TIMEVAL_H 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_time_t
|
||||
#define __need_suseconds_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct timeval
|
||||
{
|
||||
time_t tv_sec; /* Seconds. */
|
||||
suseconds_t tv_usec; /* Microseconds. */
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
85
userspace/libraries/LibC/include/complex.h
Normal file
85
userspace/libraries/LibC/include/complex.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef _COMPLEX_H
|
||||
#define _COMPLEX_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/complex.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#define complex _Complex
|
||||
#define _Complex_I (__extension__ 1.0iF)
|
||||
|
||||
#undef I
|
||||
#define I _Complex_I
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
double cabs(double complex);
|
||||
float cabsf(float complex);
|
||||
long double cabsl(long double complex);
|
||||
double complex cacos(double complex);
|
||||
float complex cacosf(float complex);
|
||||
double complex cacosh(double complex);
|
||||
float complex cacoshf(float complex);
|
||||
long double complex cacoshl(long double complex);
|
||||
long double complex cacosl(long double complex);
|
||||
double carg(double complex);
|
||||
float cargf(float complex);
|
||||
long double cargl(long double complex);
|
||||
double complex casin(double complex);
|
||||
float complex casinf(float complex);
|
||||
double complex casinh(double complex);
|
||||
float complex casinhf(float complex);
|
||||
long double complex casinhl(long double complex);
|
||||
long double complex casinl(long double complex);
|
||||
double complex catan(double complex);
|
||||
float complex catanf(float complex);
|
||||
double complex catanh(double complex);
|
||||
float complex catanhf(float complex);
|
||||
long double complex catanhl(long double complex);
|
||||
long double complex catanl(long double complex);
|
||||
double complex ccos(double complex);
|
||||
float complex ccosf(float complex);
|
||||
double complex ccosh(double complex);
|
||||
float complex ccoshf(float complex);
|
||||
long double complex ccoshl(long double complex);
|
||||
long double complex ccosl(long double complex);
|
||||
double complex cexp(double complex);
|
||||
float complex cexpf(float complex);
|
||||
long double complex cexpl(long double complex);
|
||||
double cimag(double complex);
|
||||
float cimagf(float complex);
|
||||
long double cimagl(long double complex);
|
||||
double complex clog(double complex);
|
||||
float complex clogf(float complex);
|
||||
long double complex clogl(long double complex);
|
||||
double complex conj(double complex);
|
||||
float complex conjf(float complex);
|
||||
long double complex conjl(long double complex);
|
||||
double complex cpow(double complex, double complex);
|
||||
float complex cpowf(float complex, float complex);
|
||||
long double complex cpowl(long double complex, long double complex);
|
||||
double complex cproj(double complex);
|
||||
float complex cprojf(float complex);
|
||||
long double complex cprojl(long double complex);
|
||||
double creal(double complex);
|
||||
float crealf(float complex);
|
||||
long double creall(long double complex);
|
||||
double complex csin(double complex);
|
||||
float complex csinf(float complex);
|
||||
double complex csinh(double complex);
|
||||
float complex csinhf(float complex);
|
||||
long double complex csinhl(long double complex);
|
||||
long double complex csinl(long double complex);
|
||||
double complex csqrt(double complex);
|
||||
float complex csqrtf(float complex);
|
||||
long double complex csqrtl(long double complex);
|
||||
double complex ctan(double complex);
|
||||
float complex ctanf(float complex);
|
||||
double complex ctanh(double complex);
|
||||
float complex ctanhf(float complex);
|
||||
long double complex ctanhl(long double complex);
|
||||
long double complex ctanl(long double complex);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
35
userspace/libraries/LibC/include/cpio.h
Normal file
35
userspace/libraries/LibC/include/cpio.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef _CPIO_H
|
||||
#define _CPIO_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/cpio.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define C_IRUSR 0000400
|
||||
#define C_IWUSR 0000200
|
||||
#define C_IXUSR 0000100
|
||||
#define C_IRGRP 0000040
|
||||
#define C_IWGRP 0000020
|
||||
#define C_IXGRP 0000010
|
||||
#define C_IROTH 0000004
|
||||
#define C_IWOTH 0000002
|
||||
#define C_IXOTH 0000001
|
||||
#define C_ISUID 0004000
|
||||
#define C_ISGID 0002000
|
||||
#define C_ISVTX 0001000
|
||||
#define C_ISDIR 0040000
|
||||
#define C_ISFIFO 0010000
|
||||
#define C_ISREG 0100000
|
||||
#define C_ISBLK 0060000
|
||||
#define C_ISCHR 0020000
|
||||
#define C_ISCTG 0110000
|
||||
#define C_ISLNK 0120000
|
||||
#define C_ISSOCK 0140000
|
||||
|
||||
#define MAGIC "070707"
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
48
userspace/libraries/LibC/include/ctype.h
Normal file
48
userspace/libraries/LibC/include/ctype.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _CTYPE_H
|
||||
#define _CTYPE_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <bits/types/locale_t.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int isalnum(int);
|
||||
int isalnum_l(int, locale_t);
|
||||
int isalpha(int);
|
||||
int isalpha_l(int, locale_t);
|
||||
int isascii(int);
|
||||
int isblank(int);
|
||||
int isblank_l(int, locale_t);
|
||||
int iscntrl(int);
|
||||
int iscntrl_l(int, locale_t);
|
||||
int isdigit(int);
|
||||
int isdigit_l(int, locale_t);
|
||||
int isgraph(int);
|
||||
int isgraph_l(int, locale_t);
|
||||
int islower(int);
|
||||
int islower_l(int, locale_t);
|
||||
int isprint(int);
|
||||
int isprint_l(int, locale_t);
|
||||
int ispunct(int);
|
||||
int ispunct_l(int, locale_t);
|
||||
int isspace(int);
|
||||
int isspace_l(int, locale_t);
|
||||
int isupper(int);
|
||||
int isupper_l(int, locale_t);
|
||||
int isxdigit(int);
|
||||
int isxdigit_l(int, locale_t);
|
||||
int toascii(int);
|
||||
int tolower(int);
|
||||
int tolower_l(int, locale_t);
|
||||
int toupper(int);
|
||||
int toupper_l(int, locale_t);
|
||||
|
||||
#define _toupper(val) ::toupper(val)
|
||||
#define _tolower(val) ::tolower(val)
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
45
userspace/libraries/LibC/include/dirent.h
Normal file
45
userspace/libraries/LibC/include/dirent.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef _DIRENT_H
|
||||
#define _DIRENT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_ino_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct __DIR DIR;
|
||||
|
||||
#define DT_UNKNOWN 0
|
||||
#define DT_REG 1
|
||||
#define DT_DIR 2
|
||||
#define DT_CHR 3
|
||||
#define DT_BLK 4
|
||||
#define DT_FIFO 5
|
||||
#define DT_SOCK 6
|
||||
#define DT_LNK 7
|
||||
|
||||
struct dirent
|
||||
{
|
||||
ino_t d_ino; /* File serial number. */
|
||||
unsigned char d_type; /* File type. One of DT_* definitions. */
|
||||
char d_name[256]; /* Filename string of entry. */
|
||||
};
|
||||
|
||||
int alphasort(const struct dirent** d1, const struct dirent** d2);
|
||||
int closedir(DIR* dirp);
|
||||
int dirfd(DIR* dirp);
|
||||
DIR* fdopendir(int fd);
|
||||
DIR* opendir(const char* dirname);
|
||||
struct dirent* readdir(DIR* dirp);
|
||||
int readdir_r(DIR* __restrict dirp, struct dirent* __restrict entry, struct dirent** __restrict result);
|
||||
void rewinddir(DIR* dirp);
|
||||
int scandir(const char* dir, struct dirent*** namelist, int (*sel)(const struct dirent*), int (*compar)(const struct dirent**, const struct dirent**));
|
||||
void seekdir(DIR* dirp, long loc);
|
||||
long telldir(DIR* dirp);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
22
userspace/libraries/LibC/include/dlfcn.h
Normal file
22
userspace/libraries/LibC/include/dlfcn.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef _DLFCN_H
|
||||
#define _DLFCN_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dlfcn.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define RTLD_LAZY 1
|
||||
#define RTLD_NOW 2
|
||||
#define RTLD_GLOBAL 3
|
||||
#define RTLD_LOCAL 4
|
||||
|
||||
int dlclose(void* handle);
|
||||
char* dlerror(void);
|
||||
void* dlopen(const char* file, int mode);
|
||||
void* dlsym(void* __restrict handle, const char* __restrict name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
102
userspace/libraries/LibC/include/errno.h
Normal file
102
userspace/libraries/LibC/include/errno.h
Normal file
@@ -0,0 +1,102 @@
|
||||
#ifndef _ERRNO_H
|
||||
#define _ERRNO_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define E2BIG 1
|
||||
#define EACCES 2
|
||||
#define EADDRINUSE 3
|
||||
#define EADDRNOTAVAIL 4
|
||||
#define EAFNOSUPPORT 5
|
||||
#define EAGAIN 6
|
||||
#define EALREADY 7
|
||||
#define EBADF 8
|
||||
#define EBADMSG 9
|
||||
#define EBUSY 10
|
||||
#define ECANCELED 11
|
||||
#define ECHILD 12
|
||||
#define ECONNABORTED 13
|
||||
#define ECONNREFUSED 14
|
||||
#define ECONNRESET 15
|
||||
#define EDEADLK 16
|
||||
#define EDESTADDRREQ 17
|
||||
#define EDOM 18
|
||||
#define EDQUOT 19
|
||||
#define EEXIST 20
|
||||
#define EFAULT 21
|
||||
#define EFBIG 22
|
||||
#define EHOSTUNREACH 23
|
||||
#define EIDRM 24
|
||||
#define EILSEQ 25
|
||||
#define EINPROGRESS 26
|
||||
#define EINTR 27
|
||||
#define EINVAL 28
|
||||
#define EIO 29
|
||||
#define EISCONN 30
|
||||
#define EISDIR 31
|
||||
#define ELOOP 32
|
||||
#define EMFILE 33
|
||||
#define EMLINK 34
|
||||
#define EMSGSIZE 35
|
||||
#define EMULTIHOP 36
|
||||
#define ENAMETOOLONG 37
|
||||
#define ENETDOWN 38
|
||||
#define ENETRESET 39
|
||||
#define ENETUNREACH 40
|
||||
#define ENFILE 41
|
||||
#define ENOBUFS 42
|
||||
#define ENODATA 43
|
||||
#define ENODEV 44
|
||||
#define ENOENT 45
|
||||
#define ENOEXEC 46
|
||||
#define ENOLCK 47
|
||||
#define ENOLINK 48
|
||||
#define ENOMEM 49
|
||||
#define ENOMSG 50
|
||||
#define ENOPROTOOPT 51
|
||||
#define ENOSPC 52
|
||||
#define ENOSR 53
|
||||
#define ENOSTR 54
|
||||
#define ENOSYS 55
|
||||
#define ENOTCONN 56
|
||||
#define ENOTDIR 57
|
||||
#define ENOTEMPTY 58
|
||||
#define ENOTRECOVERABLE 59
|
||||
#define ENOTSOCK 60
|
||||
#define ENOTSUP 61
|
||||
#define ENOTTY 62
|
||||
#define ENXIO 63
|
||||
#define EOPNOTSUPP 64
|
||||
#define EOVERFLOW 65
|
||||
#define EOWNERDEAD 66
|
||||
#define EPERM 67
|
||||
#define EPIPE 68
|
||||
#define EPROTO 69
|
||||
#define EPROTONOSUPPORT 70
|
||||
#define EPROTOTYPE 71
|
||||
#define ERANGE 72
|
||||
#define EROFS 73
|
||||
#define ESPIPE 74
|
||||
#define ESRCH 75
|
||||
#define ESTALE 76
|
||||
#define ETIME 77
|
||||
#define ETIMEDOUT 78
|
||||
#define ETXTBSY 79
|
||||
#define EWOULDBLOCK 80
|
||||
#define EXDEV 81
|
||||
#define ENOTBLK 82
|
||||
#define EEXISTS 83
|
||||
|
||||
#define EUNKNOWN 0xFF
|
||||
|
||||
#define errno __errno
|
||||
|
||||
extern int __errno;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
107
userspace/libraries/LibC/include/fcntl.h
Normal file
107
userspace/libraries/LibC/include/fcntl.h
Normal file
@@ -0,0 +1,107 @@
|
||||
#ifndef _FCNTL_H
|
||||
#define _FCNTL_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define __need_mode_t
|
||||
#define __need_off_t
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#define F_DUPFD 1
|
||||
#define F_DUPFD_CLOEXEC 2
|
||||
#define F_GETFD 3
|
||||
#define F_SETFD 4
|
||||
#define F_GETFL 5
|
||||
#define F_SETFL 6
|
||||
#define F_GETLK 7
|
||||
#define F_SETLK 8
|
||||
#define F_SETLKW 9
|
||||
#define F_GETOWN 10
|
||||
#define F_SETOWN 11
|
||||
|
||||
#define FD_CLOEXEC 1
|
||||
|
||||
#define F_RDLCK 1
|
||||
#define F_UNLCK 2
|
||||
#define F_WRLCK 3
|
||||
|
||||
// NOTE: also defined in stdio.h
|
||||
#define SEEK_SET 1
|
||||
#define SEEK_CUR 2
|
||||
#define SEEK_END 3
|
||||
|
||||
/* bits 4-11 */
|
||||
#define O_CLOEXEC 0x00010
|
||||
#define O_CREAT 0x00020
|
||||
#define O_DIRECTORY 0x00040
|
||||
#define O_EXCL 0x00080
|
||||
#define O_NOCTTY 0x00100
|
||||
#define O_NOFOLLOW 0x00200
|
||||
#define O_TRUNC 0x00400
|
||||
#define O_TTY_INIT 0x00800
|
||||
|
||||
/* bits 12-16 */
|
||||
#define O_APPEND 0x01000
|
||||
#define O_DSYNC 0x02000
|
||||
#define O_NONBLOCK 0x04000
|
||||
#define O_RSYNC 0x08000
|
||||
#define O_SYNC 0x10000
|
||||
|
||||
/* bits 0-3 */
|
||||
#define O_RDONLY 0x00001
|
||||
#define O_WRONLY 0x00002
|
||||
#define O_RDWR (O_RDONLY | O_WRONLY)
|
||||
#define O_SEARCH 0x00004
|
||||
#define O_EXEC 0x00008
|
||||
#define O_ACCMODE 0x0000F
|
||||
|
||||
/* bit 17 */
|
||||
#define AT_FDCWD 0x20000
|
||||
|
||||
/* bit 18 */
|
||||
#define AT_EACCESS 0x40000
|
||||
|
||||
/* bit 19 */
|
||||
#define AT_SYMLINK_NOFOLLOW 0x80000
|
||||
|
||||
/* bit 20 */
|
||||
#define AT_SYMLINK_FOLLOW 0x100000
|
||||
|
||||
/* bit 21 */
|
||||
#define AT_REMOVEDIR 0x200000
|
||||
|
||||
/* bits 22-27 */
|
||||
#define POSIX_FADV_DONTNEED 0x0400000
|
||||
#define POSIX_FADV_NOREUSE 0x0800000
|
||||
#define POSIX_FADV_NORMAL 0x1000000
|
||||
#define POSIX_FADV_RANDOM 0x2000000
|
||||
#define POSIX_FADV_SEQUENTIAL 0x4000000
|
||||
#define POSIX_FADV_WILLNEED 0x8000000
|
||||
|
||||
struct flock
|
||||
{
|
||||
short l_type; /* Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. */
|
||||
short l_whence; /* Flag for starting offset. */
|
||||
off_t l_start; /* Relative offset in bytes. */
|
||||
off_t l_len; /* Size; if 0 then until EOF. */
|
||||
pid_t l_pid; /* Process ID of the process holding the lock; returned with F_GETLK. */
|
||||
};
|
||||
|
||||
int creat(const char* path, mode_t mode);
|
||||
int fcntl(int fildes, int cmd, ...);
|
||||
int open(const char* path, int oflag, ...);
|
||||
int openat(int fd, const char* path, int oflag, ...);
|
||||
int posix_fadvise(int fd, off_t offset, off_t len, int advice);
|
||||
int posix_fallocate(int fd, off_t offset, off_t len);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
14
userspace/libraries/LibC/include/fenv.h
Normal file
14
userspace/libraries/LibC/include/fenv.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef _FENV_H
|
||||
#define _FENV_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fenv.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
// FIXME
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
42
userspace/libraries/LibC/include/fmtmsg.h
Normal file
42
userspace/libraries/LibC/include/fmtmsg.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _FMTMSG_H
|
||||
#define _FMTMSG_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fmtmsg.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define MM_HARD 1
|
||||
#define MM_SOFT 2
|
||||
#define MM_FIRM 3
|
||||
#define MM_APPL 4
|
||||
#define MM_UTIL 5
|
||||
#define MM_OPSYS 6
|
||||
#define MM_RECOVER 7
|
||||
#define MM_NRECOV 8
|
||||
#define MM_HALT 9
|
||||
#define MM_ERROR 10
|
||||
#define MM_WARNING 11
|
||||
#define MM_INFO 12
|
||||
#define MM_NOSEV 13
|
||||
#define MM_PRINT 14
|
||||
#define MM_CONSOLE 15
|
||||
|
||||
#define MM_NULLLBL (char*)0
|
||||
#define MM_NULLSEV 0
|
||||
#define MM_NULLMC 0L
|
||||
#define MM_NULLTXT (char*)0
|
||||
#define MM_NULLACL (char*)0
|
||||
#define MM_NULLTAG (char*)0
|
||||
|
||||
#define MM_OK 0
|
||||
#define MM_NOTOK 1
|
||||
#define MM_NOMSG 2
|
||||
#define MM_NOCON 3
|
||||
|
||||
int fmtmsg(long classification, const char* label, int severity, const char* text, const char* action, const char* tag);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
19
userspace/libraries/LibC/include/fnmatch.h
Normal file
19
userspace/libraries/LibC/include/fnmatch.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _FNMATCH_H
|
||||
#define _FNMATCH_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fnmatch.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define FNM_NOMATCH 1
|
||||
#define FNM_PATHNAME 0x01
|
||||
#define FNM_PERIOD 0x02
|
||||
#define FNM_NOESCAPE 0x04
|
||||
|
||||
int fnmatch(const char* pattern, const char* string, int flags);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
36
userspace/libraries/LibC/include/ftw.h
Normal file
36
userspace/libraries/LibC/include/ftw.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef _FTW_H
|
||||
#define _FTW_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ftw.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
struct FTW
|
||||
{
|
||||
int base;
|
||||
int level;
|
||||
};
|
||||
|
||||
#define FTW_F 1
|
||||
#define FTW_D 2
|
||||
#define FTW_DNR 3
|
||||
#define FTW_DP 4
|
||||
#define FTW_NS 5
|
||||
#define FTW_SL 6
|
||||
#define FTW_SLN 7
|
||||
|
||||
#define FTW_PHYS 1
|
||||
#define FTW_MOUNT 2
|
||||
#define FTW_DEPTH 3
|
||||
#define FTW_CHDIR 4
|
||||
|
||||
int ftw(const char* path, int (*fn)(const char*, const struct stat* ptr, int flag), int ndirs);
|
||||
int nftw(const char* path, int (*fn)(const char*, const struct stat*, int, struct FTW*), int fd_limit, int flags);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
37
userspace/libraries/LibC/include/glob.h
Normal file
37
userspace/libraries/LibC/include/glob.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _GLOB_H
|
||||
#define _GLOB_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/glob.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#define GLOB_APPEND 0x01
|
||||
#define GLOB_DOOFFS 0x02
|
||||
#define GLOB_ERR 0x04
|
||||
#define GLOB_MARK 0x08
|
||||
#define GLOB_NOCHECK 0x10
|
||||
#define GLOB_NOESCAPE 0x20
|
||||
#define GLOB_NOSORT 0x40
|
||||
|
||||
#define GLOB_ABORTED 1
|
||||
#define GLOB_NOMATCH 2
|
||||
#define GLOB_NOSPACE 3
|
||||
|
||||
struct glob_t
|
||||
{
|
||||
size_t gl_pathc; /* Count of paths matched by pattern. */
|
||||
char** gl_pathv; /* Pointer to a list of matched pathnames. */
|
||||
size_t gl_offs; /* Slots to reserve at the beginning of gl_pathv. */
|
||||
};
|
||||
|
||||
int glob(const char* __restrict pattern, int flags, int (*errfunc)(const char* epath, int eerrno), glob_t* __restrict pglob);
|
||||
void globfree(glob_t* pglob);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
31
userspace/libraries/LibC/include/grp.h
Normal file
31
userspace/libraries/LibC/include/grp.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef _GRP_H
|
||||
#define _GRP_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/grp.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_gid_t
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct group
|
||||
{
|
||||
char* gr_name; /* The name of the group. */
|
||||
gid_t gr_gid; /* Numerical group ID. */
|
||||
char** gr_mem; /* Pointer to a null-terminated array of character pointers to member names. */
|
||||
};
|
||||
|
||||
void endgrent(void);
|
||||
struct group* getgrent(void);
|
||||
struct group* getgrgid(gid_t gid);
|
||||
int getgrgit_r(gid_t gid, struct group* grp, char* buffer, size_t bufsize, struct group** result);
|
||||
struct group* getgrnam(const char* name);
|
||||
int getgrnam_r(const char* name, struct group* grp, char* buffer, size_t bufsize, struct group** result);
|
||||
void setgrent(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
21
userspace/libraries/LibC/include/iconv.h
Normal file
21
userspace/libraries/LibC/include/iconv.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _ICONV_H
|
||||
#define _ICONV_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/iconv.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef void* iconv_t;
|
||||
|
||||
size_t iconv(iconv_t cd, char** __restrict inbuf, size_t* __restrict inbytesleft, char** __restrict outbuf, size_t* __restrict outbytesleft);
|
||||
int iconv_close(iconv_t cd);
|
||||
iconv_t iconv_open(const char* tocode, const char* fromcode);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
10
userspace/libraries/LibC/include/icxxabi.h
Normal file
10
userspace/libraries/LibC/include/icxxabi.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int __cxa_atexit(void (*func)(void*), void* data, void* dso_handle);
|
||||
void __cxa_finalize(void* func);
|
||||
|
||||
__END_DECLS
|
||||
203
userspace/libraries/LibC/include/inttypes.h
Normal file
203
userspace/libraries/LibC/include/inttypes.h
Normal file
@@ -0,0 +1,203 @@
|
||||
#ifndef _INTTYPES_H
|
||||
#define _INTTYPES_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define __need_wchar_t
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
intmax_t quot;
|
||||
intmax_t rem;
|
||||
} imaxdiv_t;
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define __PRI64_PREFIX "l"
|
||||
#define __PRIPTR_PREFIX "l"
|
||||
#else
|
||||
#define __PRI64_PREFIX "ll"
|
||||
#define __PRIPTR_PREFIX
|
||||
#endif
|
||||
|
||||
#define PRId8 "d"
|
||||
#define PRId16 "d"
|
||||
#define PRId32 "d"
|
||||
#define PRId64 __PRI64_PREFIX "d"
|
||||
#define PRIdLEAST8 "d"
|
||||
#define PRIdLEAST16 "d"
|
||||
#define PRIdLEAST32 "d"
|
||||
#define PRIdLEAST64 __PRI64_PREFIX "d"
|
||||
#define PRIdFAST8 "d"
|
||||
#define PRIdFAST16 __PRIPTR_PREFIX "d"
|
||||
#define PRIdFAST32 __PRIPTR_PREFIX "d"
|
||||
#define PRIdFAST64 __PRI64_PREFIX "d"
|
||||
#define PRIdMAX __PRI64_PREFIX "d"
|
||||
#define PRIdPTR __PRIPTR_PREFIX "d"
|
||||
|
||||
#define PRIi8 "i"
|
||||
#define PRIi16 "i"
|
||||
#define PRIi32 "i"
|
||||
#define PRIi64 __PRI64_PREFIX "i"
|
||||
#define PRIiLEAST8 "i"
|
||||
#define PRIiLEAST16 "i"
|
||||
#define PRIiLEAST32 "i"
|
||||
#define PRIiLEAST64 __PRI64_PREFIX "i"
|
||||
#define PRIiFAST8 "i"
|
||||
#define PRIiFAST16 __PRIPTR_PREFIX "i"
|
||||
#define PRIiFAST32 __PRIPTR_PREFIX "i"
|
||||
#define PRIiFAST64 __PRI64_PREFIX "i"
|
||||
#define PRIiMAX __PRI64_PREFIX "i"
|
||||
#define PRIiPTR __PRIPTR_PREFIX "i"
|
||||
|
||||
#define PRIo8 "o"
|
||||
#define PRIo16 "o"
|
||||
#define PRIo32 "o"
|
||||
#define PRIo64 __PRI64_PREFIX "o"
|
||||
#define PRIoLEAST8 "o"
|
||||
#define PRIoLEAST16 "o"
|
||||
#define PRIoLEAST32 "o"
|
||||
#define PRIoLEAST64 __PRI64_PREFIX "o"
|
||||
#define PRIoFAST8 "o"
|
||||
#define PRIoFAST16 __PRIPTR_PREFIX "o"
|
||||
#define PRIoFAST32 __PRIPTR_PREFIX "o"
|
||||
#define PRIoFAST64 __PRI64_PREFIX "o"
|
||||
#define PRIoMAX __PRI64_PREFIX "o"
|
||||
#define PRIoPTR __PRIPTR_PREFIX "o"
|
||||
|
||||
#define PRIu8 "u"
|
||||
#define PRIu16 "u"
|
||||
#define PRIu32 "u"
|
||||
#define PRIu64 __PRI64_PREFIX "u"
|
||||
#define PRIuLEAST8 "u"
|
||||
#define PRIuLEAST16 "u"
|
||||
#define PRIuLEAST32 "u"
|
||||
#define PRIuLEAST64 __PRI64_PREFIX "u"
|
||||
#define PRIuFAST8 "u"
|
||||
#define PRIuFAST16 __PRIPTR_PREFIX "u"
|
||||
#define PRIuFAST32 __PRIPTR_PREFIX "u"
|
||||
#define PRIuFAST64 __PRI64_PREFIX "u"
|
||||
#define PRIuMAX __PRI64_PREFIX "u"
|
||||
#define PRIuPTR __PRIPTR_PREFIX "u"
|
||||
|
||||
#define PRIx8 "x"
|
||||
#define PRIx16 "x"
|
||||
#define PRIx32 "x"
|
||||
#define PRIx64 __PRI64_PREFIX "x"
|
||||
#define PRIxLEAST8 "x"
|
||||
#define PRIxLEAST16 "x"
|
||||
#define PRIxLEAST32 "x"
|
||||
#define PRIxLEAST64 __PRI64_PREFIX "x"
|
||||
#define PRIxFAST8 "x"
|
||||
#define PRIxFAST16 __PRIPTR_PREFIX "x"
|
||||
#define PRIxFAST32 __PRIPTR_PREFIX "x"
|
||||
#define PRIxFAST64 __PRI64_PREFIX "x"
|
||||
#define PRIxMAX __PRI64_PREFIX "x"
|
||||
#define PRIxPTR __PRIPTR_PREFIX "x"
|
||||
|
||||
#define PRIX8 "X"
|
||||
#define PRIX16 "X"
|
||||
#define PRIX32 "X"
|
||||
#define PRIX64 __PRI64_PREFIX "X"
|
||||
#define PRIXLEAST8 "X"
|
||||
#define PRIXLEAST16 "X"
|
||||
#define PRIXLEAST32 "X"
|
||||
#define PRIXLEAST64 __PRI64_PREFIX "X"
|
||||
#define PRIXFAST8 "X"
|
||||
#define PRIXFAST16 __PRIPTR_PREFIX "X"
|
||||
#define PRIXFAST32 __PRIPTR_PREFIX "X"
|
||||
#define PRIXFAST64 __PRI64_PREFIX "X"
|
||||
#define PRIXMAX __PRI64_PREFIX "X"
|
||||
#define PRIXPTR __PRIPTR_PREFIX "X"
|
||||
|
||||
#define SCNd8 "hhd"
|
||||
#define SCNd16 "hd"
|
||||
#define SCNd32 "d"
|
||||
#define SCNd64 __PRI64_PREFIX "d"
|
||||
#define SCNdLEAST8 "hhd"
|
||||
#define SCNdLEAST16 "hd"
|
||||
#define SCNdLEAST32 "d"
|
||||
#define SCNdLEAST64 __PRI64_PREFIX "d"
|
||||
#define SCNdFAST8 "hhd"
|
||||
#define SCNdFAST16 __PRIPTR_PREFIX "d"
|
||||
#define SCNdFAST32 __PRIPTR_PREFIX "d"
|
||||
#define SCNdFAST64 __PRI64_PREFIX "d"
|
||||
#define SCNdMAX __PRI64_PREFIX "d"
|
||||
#define SCNdPTR __PRIPTR_PREFIX "d"
|
||||
|
||||
#define SCNi8 "hhi"
|
||||
#define SCNi16 "hi"
|
||||
#define SCNi32 "i"
|
||||
#define SCNi64 __PRI64_PREFIX "i"
|
||||
#define SCNiLEAST8 "hhi"
|
||||
#define SCNiLEAST16 "hi"
|
||||
#define SCNiLEAST32 "i"
|
||||
#define SCNiLEAST64 __PRI64_PREFIX "i"
|
||||
#define SCNiFAST8 "hhi"
|
||||
#define SCNiFAST16 __PRIPTR_PREFIX "i"
|
||||
#define SCNiFAST32 __PRIPTR_PREFIX "i"
|
||||
#define SCNiFAST64 __PRI64_PREFIX "i"
|
||||
#define SCNiMAX __PRI64_PREFIX "i"
|
||||
#define SCNiPTR __PRIPTR_PREFIX "i"
|
||||
|
||||
#define SCNo8 "hho"
|
||||
#define SCNo16 "ho"
|
||||
#define SCNo32 "o"
|
||||
#define SCNo64 __PRI64_PREFIX "o"
|
||||
#define SCNoLEAST8 "hho"
|
||||
#define SCNoLEAST16 "ho"
|
||||
#define SCNoLEAST32 "o"
|
||||
#define SCNoLEAST64 __PRI64_PREFIX "o"
|
||||
#define SCNoFAST8 "hho"
|
||||
#define SCNoFAST16 __PRIPTR_PREFIX "o"
|
||||
#define SCNoFAST32 __PRIPTR_PREFIX "o"
|
||||
#define SCNoFAST64 __PRI64_PREFIX "o"
|
||||
#define SCNoMAX __PRI64_PREFIX "o"
|
||||
#define SCNoPTR __PRIPTR_PREFIX "o"
|
||||
|
||||
#define SCNu8 "hhu"
|
||||
#define SCNu16 "hu"
|
||||
#define SCNu32 "u"
|
||||
#define SCNu64 __PRI64_PREFIX "u"
|
||||
#define SCNuLEAST8 "hhu"
|
||||
#define SCNuLEAST16 "hu"
|
||||
#define SCNuLEAST32 "u"
|
||||
#define SCNuLEAST64 __PRI64_PREFIX "u"
|
||||
#define SCNuFAST8 "hhu"
|
||||
#define SCNuFAST16 __PRIPTR_PREFIX "u"
|
||||
#define SCNuFAST32 __PRIPTR_PREFIX "u"
|
||||
#define SCNuFAST64 __PRI64_PREFIX "u"
|
||||
#define SCNuMAX __PRI64_PREFIX "u"
|
||||
#define SCNuPTR __PRIPTR_PREFIX "u"
|
||||
|
||||
#define SCNx8 "hhx"
|
||||
#define SCNx16 "hx"
|
||||
#define SCNx32 "x"
|
||||
#define SCNx64 __PRI64_PREFIX "x"
|
||||
#define SCNxLEAST8 "hhx"
|
||||
#define SCNxLEAST16 "hx"
|
||||
#define SCNxLEAST32 "x"
|
||||
#define SCNxLEAST64 __PRI64_PREFIX "x"
|
||||
#define SCNxFAST8 "hhx"
|
||||
#define SCNxFAST16 __PRIPTR_PREFIX "x"
|
||||
#define SCNxFAST32 __PRIPTR_PREFIX "x"
|
||||
#define SCNxFAST64 __PRI64_PREFIX "x"
|
||||
#define SCNxMAX __PRI64_PREFIX "x"
|
||||
#define SCNxPTR __PRIPTR_PREFIX "x"
|
||||
|
||||
intmax_t imaxabs(intmax_t);
|
||||
imaxdiv_t imaxdiv(intmax_t, intmax_t);
|
||||
intmax_t strtoimax(const char* __restrict nptr, char** __restrict endptr, int base);
|
||||
uintmax_t strtoumax(const char* __restrict nptr, char** __restrict endptr, int base);
|
||||
intmax_t wcstoimax(const wchar_t* __restrict nptr, wchar_t** __restrict endptr, int base);
|
||||
uintmax_t wcstoumax(const wchar_t* __restrict nptr, wchar_t** __restrict endptr, int base);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
74
userspace/libraries/LibC/include/langinfo.h
Normal file
74
userspace/libraries/LibC/include/langinfo.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef _LANGINFO_H
|
||||
#define _LANGINFO_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <bits/types/locale_t.h>
|
||||
#include <nl_types.h>
|
||||
|
||||
#define CODESET 0
|
||||
#define D_T_FMT 1
|
||||
#define D_FMT 2
|
||||
#define T_FMT 3
|
||||
#define T_FMT_AMPM 4
|
||||
#define AM_STR 5
|
||||
#define PM_STR 6
|
||||
#define DAY_1 7
|
||||
#define DAY_2 8
|
||||
#define DAY_3 9
|
||||
#define DAY_4 10
|
||||
#define DAY_5 11
|
||||
#define DAY_6 12
|
||||
#define DAY_7 13
|
||||
#define ABDAY_1 14
|
||||
#define ABDAY_2 15
|
||||
#define ABDAY_3 16
|
||||
#define ABDAY_4 17
|
||||
#define ABDAY_5 18
|
||||
#define ABDAY_6 19
|
||||
#define ABDAY_7 20
|
||||
#define MON_1 21
|
||||
#define MON_2 22
|
||||
#define MON_3 23
|
||||
#define MON_4 24
|
||||
#define MON_5 25
|
||||
#define MON_6 26
|
||||
#define MON_7 27
|
||||
#define MON_8 28
|
||||
#define MON_9 29
|
||||
#define MON_10 30
|
||||
#define MON_11 31
|
||||
#define MON_12 32
|
||||
#define ABMON_1 33
|
||||
#define ABMON_2 34
|
||||
#define ABMON_3 35
|
||||
#define ABMON_4 36
|
||||
#define ABMON_5 37
|
||||
#define ABMON_6 38
|
||||
#define ABMON_7 39
|
||||
#define ABMON_8 40
|
||||
#define ABMON_9 41
|
||||
#define ABMON_10 42
|
||||
#define ABMON_11 43
|
||||
#define ABMON_12 44
|
||||
#define ERA 45
|
||||
#define ERA_D_FMT 46
|
||||
#define ERA_D_T_FMT 47
|
||||
#define ERA_T_FMT 48
|
||||
#define ALT_DIGITS 49
|
||||
#define RADIXCHAR 50
|
||||
#define THOUSEP 51
|
||||
#define YESEXPR 52
|
||||
#define NOEXPR 53
|
||||
#define CRNCYSTR 54
|
||||
|
||||
char* nl_langinfo(nl_item item);
|
||||
char* nl_landinfo_l(nl_item item, locale_t locale);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
15
userspace/libraries/LibC/include/libgen.h
Normal file
15
userspace/libraries/LibC/include/libgen.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef _LIBGEN_H
|
||||
#define _LIBGEN_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ligen.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
char* basename(char* path);
|
||||
char* dirname(char* path);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
68
userspace/libraries/LibC/include/limits.h
Normal file
68
userspace/libraries/LibC/include/limits.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef _LIMITS_H
|
||||
#define _LIMITS_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define _POSIX_AIO_LISTIO_MAX 2
|
||||
#define _POSIX_AIO_MAX 1
|
||||
#define _POSIX_ARG_MAX 4096
|
||||
#define _POSIX_CHILD_MAX 25
|
||||
#define _POSIX_DELAYTIMER_MAX 32
|
||||
#define _POSIX_HOST_NAME_MAX 255
|
||||
#define _POSIX_LINK_MAX 8
|
||||
#define _POSIX_LOGIN_NAME_MAX 9
|
||||
#define _POSIX_MAX_CANON 255
|
||||
#define _POSIX_MAX_INPUT 255
|
||||
#define _POSIX_MQ_OPEN_MAX 8
|
||||
#define _POSIX_MQ_PRIO_MAX 32
|
||||
#define _POSIX_NAME_MAX 14
|
||||
#define _POSIX_NGROUPS_MAX 8
|
||||
#define _POSIX_OPEN_MAX 20
|
||||
#define _POSIX_PATH_MAX 256
|
||||
#define _POSIX_PIPE_BUF 512
|
||||
#define _POSIX_RE_DUP_MAX 255
|
||||
#define _POSIX_RTSIG_MAX 8
|
||||
#define _POSIX_SEM_NSEMS_MAX 256
|
||||
#define _POSIX_SEM_VALUE_MAX 32767
|
||||
#define _POSIX_SIGQUEUE_MAX 32
|
||||
#define _POSIX_SSIZE_MAX 32767
|
||||
#define _POSIX_SS_REPL_MAX 4
|
||||
#define _POSIX_STREAM_MAX 8
|
||||
#define _POSIX_SYMLINK_MAX 255
|
||||
#define _POSIX_SYMLOOP_MAX 8
|
||||
#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4
|
||||
#define _POSIX_THREAD_KEYS_MAX 128
|
||||
#define _POSIX_THREAD_THREADS_MAX 64
|
||||
#define _POSIX_TIMER_MAX 32
|
||||
#define _POSIX_TRACE_EVENT_NAME_MAX 30
|
||||
#define _POSIX_TRACE_NAME_MAX 8
|
||||
#define _POSIX_TRACE_SYS_MAX 8
|
||||
#define _POSIX_TRACE_USER_EVENT_MAX 32
|
||||
#define _POSIX_TTY_NAME_MAX 9
|
||||
#define _POSIX_TZNAME_MAX 6
|
||||
#define _POSIX2_BC_BASE_MAX 99
|
||||
#define _POSIX2_BC_DIM_MAX 2048
|
||||
#define _POSIX2_BC_SCALE_MAX 99
|
||||
#define _POSIX2_BC_STRING_MAX 1000
|
||||
#define _POSIX2_CHARCLASS_NAME_MAX 14
|
||||
#define _POSIX2_COLL_WEIGHTS_MAX 2
|
||||
#define _POSIX2_EXPR_NEST_MAX 32
|
||||
#define _POSIX2_LINE_MAX 2048
|
||||
#define _POSIX2_RE_DUP_MAX 255
|
||||
#define _XOPEN_IOV_MAX 16
|
||||
#define _XOPEN_NAME_MAX 255
|
||||
#define _XOPEN_PATH_MAX 1024
|
||||
|
||||
#define OPEN_MAX 64
|
||||
#define NAME_MAX 255
|
||||
#define PATH_MAX 256
|
||||
#define LOGIN_NAME_MAX 256
|
||||
#define HOST_NAME_MAX 255
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
73
userspace/libraries/LibC/include/locale.h
Normal file
73
userspace/libraries/LibC/include/locale.h
Normal file
@@ -0,0 +1,73 @@
|
||||
#ifndef _LOCALE_H
|
||||
#define _LOCALE_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/locale.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <bits/types/locale_t.h>
|
||||
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#define LC_COLLATE 0
|
||||
#define LC_CTYPE 1
|
||||
#define LC_MESSAGES 2
|
||||
#define LC_MONETARY 3
|
||||
#define LC_NUMERIC 4
|
||||
#define LC_TIME 5
|
||||
#define LC_ALL 6
|
||||
|
||||
#define LC_COLLATE_MASK (1 << LC_COLLATE)
|
||||
#define LC_CTYPE_MASK (1 << LC_CTYPE)
|
||||
#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
|
||||
#define LC_MONETARY_MASK (1 << LC_MONETARY)
|
||||
#define LC_NUMERIC_MASK (1 << LC_NUMERIC)
|
||||
#define LC_TIME_MASK (1 << LC_TIME)
|
||||
#define LC_ALL_MASK LC_COLLATE_MASK \
|
||||
| LC_CTYPE_MASK \
|
||||
| LC_MESSAGES_MASK \
|
||||
| LC_MONETARY_MASK \
|
||||
| LC_NUMERIC_MASK \
|
||||
| LC_TIME_MASK
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct lconv
|
||||
{
|
||||
char* currency_symbol;
|
||||
char* decimal_point;
|
||||
char frac_digits;
|
||||
char* grouping;
|
||||
char* int_curr_symbol;
|
||||
char int_frac_digits;
|
||||
char int_n_cs_precedes;
|
||||
char int_n_sep_by_space;
|
||||
char int_n_sign_posn;
|
||||
char int_p_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
char* mon_decimal_point;
|
||||
char* mon_grouping;
|
||||
char* mon_thousands_sep;
|
||||
char* negative_sign;
|
||||
char n_cs_precedes;
|
||||
char n_sep_by_space;
|
||||
char n_sign_posn;
|
||||
char* positive_sign;
|
||||
char p_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char* thousands_sep;
|
||||
};
|
||||
|
||||
locale_t duplocale(locale_t locobj);
|
||||
void freelocale(locale_t locobj);
|
||||
struct lconv* localeconv(void);
|
||||
locale_t newlocale(int category_mask, const char* locale, locale_t base);
|
||||
char* setlocale(int category, const char* locale);
|
||||
locale_t uselocale(locale_t newloc);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
256
userspace/libraries/LibC/include/math.h
Normal file
256
userspace/libraries/LibC/include/math.h
Normal file
@@ -0,0 +1,256 @@
|
||||
#ifndef _MATH_H
|
||||
#define _MATH_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#ifndef FLT_EVAL_METHOD
|
||||
#define FLT_EVAL_METHOD 0
|
||||
#endif
|
||||
|
||||
#if FLT_EVAL_METHOD == 0
|
||||
typedef float float_t;
|
||||
typedef double double_t;
|
||||
#elif FLT_EVAL_METHOD == 1
|
||||
typedef double float_t;
|
||||
typedef double double_t;
|
||||
#elif FLT_EVAL_METHOD == 2
|
||||
typedef long double float_t;
|
||||
typedef long double double_t;
|
||||
#endif
|
||||
|
||||
// FIXME: define this
|
||||
// int fpclassify(real-floating x);
|
||||
|
||||
#define isfinite(x) __builtin_isfinite(x)
|
||||
#define isgreater(x, y) __builtin_isgreater(x, y)
|
||||
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
|
||||
#define isinf(x) __builtin_isinf_sign(x)
|
||||
#define isless(x, y) __builtin_isless(x, y)
|
||||
#define islessequal(x, y) __builtin_islessequal(x, y)
|
||||
#define islessgreater(x, y) __builtin_islessgreater(x, y)
|
||||
#define isnan(x) __builtin_isnan(x)
|
||||
#define isnormal(x) __builtin_isnormal(x)
|
||||
#define isunordered(x, y) __builtin_isunordered(x, y)
|
||||
#define signbit(x) __builtin_signbit(x)
|
||||
|
||||
#define M_E 2.7182818284590452354
|
||||
#define M_LOG2E 1.4426950408889634074
|
||||
#define M_LOG10E 0.43429448190325182765
|
||||
#define M_LN2 0.69314718055994530942
|
||||
#define M_LN10 2.30258509299404568402
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#define M_PI_4 0.78539816339744830962
|
||||
#define M_1_PI 0.31830988618379067154
|
||||
#define M_2_PI 0.63661977236758134308
|
||||
#define M_2_SQRTPI 1.12837916709551257390
|
||||
#define M_SQRT2 1.41421356237309504880
|
||||
#define M_SQRT1_2 0.70710678118654752440
|
||||
|
||||
#define HUGE_VAL __builtin_huge_val()
|
||||
#define HUGE_VALF __builtin_huge_valf()
|
||||
#define HUGE_VALL __builtin_huge_vall()
|
||||
#define INFINITY __builtin_inff()
|
||||
#define NAN __builtin_nanf("")
|
||||
|
||||
#define FP_INFINITE 0
|
||||
#define FP_NAN 1
|
||||
#define FP_NORMAL 2
|
||||
#define FP_SUBNORMAL 3
|
||||
#define FP_ZERO 4
|
||||
|
||||
#define FP_ILOGB0 -2147483647
|
||||
#define FP_ILOGBNAN +2147483647
|
||||
|
||||
#define MATH_ERRNO 1
|
||||
#define MATH_ERREXCEPT 2
|
||||
|
||||
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
|
||||
|
||||
double acos(double);
|
||||
float acosf(float);
|
||||
double acosh(double);
|
||||
float acoshf(float);
|
||||
long double acoshl(long double);
|
||||
long double acosl(long double);
|
||||
double asin(double);
|
||||
float asinf(float);
|
||||
double asinh(double);
|
||||
float asinhf(float);
|
||||
long double asinhl(long double);
|
||||
long double asinl(long double);
|
||||
double atan(double);
|
||||
double atan2(double, double);
|
||||
float atan2f(float, float);
|
||||
long double atan2l(long double, long double);
|
||||
float atanf(float);
|
||||
double atanh(double);
|
||||
float atanhf(float);
|
||||
long double atanhl(long double);
|
||||
long double atanl(long double);
|
||||
double cbrt(double);
|
||||
float cbrtf(float);
|
||||
long double cbrtl(long double);
|
||||
double ceil(double);
|
||||
float ceilf(float);
|
||||
long double ceill(long double);
|
||||
double copysign(double, double);
|
||||
float copysignf(float, float);
|
||||
long double copysignl(long double, long double);
|
||||
double cos(double);
|
||||
float cosf(float);
|
||||
double cosh(double);
|
||||
float coshf(float);
|
||||
long double coshl(long double);
|
||||
long double cosl(long double);
|
||||
double erf(double);
|
||||
double erfc(double);
|
||||
float erfcf(float);
|
||||
long double erfcl(long double);
|
||||
float erff(float);
|
||||
long double erfl(long double);
|
||||
double exp(double);
|
||||
double exp2(double);
|
||||
float exp2f(float);
|
||||
long double exp2l(long double);
|
||||
float expf(float);
|
||||
long double expl(long double);
|
||||
double expm1(double);
|
||||
float expm1f(float);
|
||||
long double expm1l(long double);
|
||||
double fabs(double);
|
||||
float fabsf(float);
|
||||
long double fabsl(long double);
|
||||
double fdim(double, double);
|
||||
float fdimf(float, float);
|
||||
long double fdiml(long double, long double);
|
||||
double floor(double);
|
||||
float floorf(float);
|
||||
long double floorl(long double);
|
||||
double fma(double, double, double);
|
||||
float fmaf(float, float, float);
|
||||
long double fmal(long double, long double, long double);
|
||||
double fmax(double, double);
|
||||
float fmaxf(float, float);
|
||||
long double fmaxl(long double, long double);
|
||||
double fmin(double, double);
|
||||
float fminf(float, float);
|
||||
long double fminl(long double, long double);
|
||||
double fmod(double, double);
|
||||
float fmodf(float, float);
|
||||
long double fmodl(long double, long double);
|
||||
double frexp(double, int*);
|
||||
float frexpf(float, int*);
|
||||
long double frexpl(long double, int*);
|
||||
double hypot(double, double);
|
||||
float hypotf(float, float);
|
||||
long double hypotl(long double, long double);
|
||||
int ilogb(double);
|
||||
int ilogbf(float);
|
||||
int ilogbl(long double);
|
||||
double j0(double);
|
||||
double j1(double);
|
||||
double jn(int, double);
|
||||
double ldexp(double, int);
|
||||
float ldexpf(float, int);
|
||||
long double ldexpl(long double, int);
|
||||
double lgamma(double);
|
||||
float lgammaf(float);
|
||||
long double lgammal(long double);
|
||||
long long llrint(double);
|
||||
long long llrintf(float);
|
||||
long long llrintl(long double);
|
||||
long long llround(double);
|
||||
long long llroundf(float);
|
||||
long long llroundl(long double);
|
||||
double log(double);
|
||||
double log10(double);
|
||||
float log10f(float);
|
||||
long double log10l(long double);
|
||||
double log1p(double);
|
||||
float log1pf(float);
|
||||
long double log1pl(long double);
|
||||
double log2(double);
|
||||
float log2f(float);
|
||||
long double log2l(long double);
|
||||
double logb(double);
|
||||
float logbf(float);
|
||||
long double logbl(long double);
|
||||
float logf(float);
|
||||
long double logl(long double);
|
||||
long lrint(double);
|
||||
long lrintf(float);
|
||||
long lrintl(long double);
|
||||
long lround(double);
|
||||
long lroundf(float);
|
||||
long lroundl(long double);
|
||||
double modf(double, double*);
|
||||
float modff(float, float*);
|
||||
long double modfl(long double, long double*);
|
||||
double nan(const char*);
|
||||
float nanf(const char*);
|
||||
long double nanl(const char*);
|
||||
double nearbyint(double);
|
||||
float nearbyintf(float);
|
||||
long double nearbyintl(long double);
|
||||
double nextafter(double, double);
|
||||
float nextafterf(float, float);
|
||||
long double nextafterl(long double, long double);
|
||||
double nexttoward(double, long double);
|
||||
float nexttowardf(float, long double);
|
||||
long double nexttowardl(long double, long double);
|
||||
double pow(double, double);
|
||||
float powf(float, float);
|
||||
long double powl(long double, long double);
|
||||
double remainder(double, double);
|
||||
float remainderf(float, float);
|
||||
long double remainderl(long double, long double);
|
||||
double remquo(double, double, int*);
|
||||
float remquof(float, float, int*);
|
||||
long double remquol(long double, long double, int*);
|
||||
double rint(double);
|
||||
float rintf(float);
|
||||
long double rintl(long double);
|
||||
double round(double);
|
||||
float roundf(float);
|
||||
long double roundl(long double);
|
||||
double scalbln(double, long);
|
||||
float scalblnf(float, long);
|
||||
long double scalblnl(long double, long);
|
||||
double scalbn(double, int);
|
||||
float scalbnf(float, int);
|
||||
long double scalbnl(long double, int);
|
||||
double sin(double);
|
||||
float sinf(float);
|
||||
double sinh(double);
|
||||
float sinhf(float);
|
||||
long double sinhl(long double);
|
||||
long double sinl(long double);
|
||||
double sqrt(double);
|
||||
float sqrtf(float);
|
||||
long double sqrtl(long double);
|
||||
double tan(double);
|
||||
float tanf(float);
|
||||
double tanh(double);
|
||||
float tanhf(float);
|
||||
long double tanhl(long double);
|
||||
long double tanl(long double);
|
||||
double tgamma(double);
|
||||
float tgammaf(float);
|
||||
long double tgammal(long double);
|
||||
double trunc(double);
|
||||
float truncf(float);
|
||||
long double truncl(long double);
|
||||
double y0(double);
|
||||
double y1(double);
|
||||
double yn(int, double);
|
||||
|
||||
extern int signgam;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
23
userspace/libraries/LibC/include/monetary.h
Normal file
23
userspace/libraries/LibC/include/monetary.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _MONETARY_H
|
||||
#define _MONETARY_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/monetary.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <bits/types/locale_t.h>
|
||||
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
|
||||
#define __need_ssize_t
|
||||
#include <sys/types.h>
|
||||
|
||||
ssize_t strfmon(char* __restrict s, size_t maxsize, const char* __restrict format, ...);
|
||||
ssize_t strfmon_l(char* __restrict s, size_t maxsize, locale_t locale, const char* __restrict format, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
41
userspace/libraries/LibC/include/mqueue.h
Normal file
41
userspace/libraries/LibC/include/mqueue.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef _MQUEUE_H
|
||||
#define _MQUEUE_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/mqueue.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define __need_pthread_attr_t
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef int mqd_t;
|
||||
|
||||
struct mq_attr
|
||||
{
|
||||
long mq_flags; /* Message queue flags. */
|
||||
long mq_maxmsg; /* Maximum number of messages. */
|
||||
long mq_msgsize; /* Maximum message size. */
|
||||
long mq_curmsgs; /* Number of messages currently queued. */
|
||||
};
|
||||
|
||||
int mq_close(mqd_t mqdes);
|
||||
int mq_getattr(mqd_t mqdes, struct mq_attr* mqstat);
|
||||
int mq_notify(mqd_t mqdes, const struct sigevent* notification);
|
||||
mqd_t mq_open(const char* name, int oflag, ...);
|
||||
ssize_t mq_receive(mqd_t mqdes, char* msq_ptr, size_t msq_len, unsigned* msg_prio);
|
||||
int mq_send(mqd_t mqdes, const char* msg_ptr, size_t msg_len, unsigned msg_prio);
|
||||
int mq_setattr(mqd_t mqdes, const struct mq_attr* __restrict mqstat, struct mq_attr* __restrict omqstat);
|
||||
ssize_t mq_timedreceive(mqd_t mqdes, char* __restrict msg_ptr, size_t msg_len, unsigned* __restrict msg_prio, const struct timespec* __restrict abstime);
|
||||
int mq_timedsend(mqd_t mqdes, const char* msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec* abstime);
|
||||
int mq_unlink(const char* name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
39
userspace/libraries/LibC/include/ndbm.h
Normal file
39
userspace/libraries/LibC/include/ndbm.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef _NDBM_H
|
||||
#define _NDBM_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ndbm.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define DBM_REPLACE 1
|
||||
#define DBM_INSERT 0
|
||||
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
|
||||
#define __need_mode_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void* dptr; /* A pointer to the application's data. */
|
||||
size_t dsize; /* The size of the object pointed to by dptr */
|
||||
} datum;
|
||||
|
||||
typedef int DBM;
|
||||
|
||||
int dbm_clearerr(DBM* db);
|
||||
void dbm_close(DBM* db);
|
||||
int dbm_delete(DBM* db, datum key);
|
||||
int dbm_error(DBM* db);
|
||||
datum dbm_fetch(DBM* db, datum key);
|
||||
datum dbm_firstkey(DBM* db);
|
||||
datum dbm_nextkey(DBM* db);
|
||||
DBM* dbm_open(const char* file, int open_flags, mode_t file_mode);
|
||||
int dbm_store(DBM* db, datum key, datum content, int store_mode);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
46
userspace/libraries/LibC/include/net/if.h
Normal file
46
userspace/libraries/LibC/include/net/if.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef _NET_IF_H
|
||||
#define _NET_IF_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define IF_NAMESIZE 16
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct if_nameindex
|
||||
{
|
||||
unsigned if_index; /* Numeric index of the interface. */
|
||||
char* if_name; /* Null-terminated name of the interface. */
|
||||
};
|
||||
|
||||
struct ifreq
|
||||
{
|
||||
union {
|
||||
struct sockaddr ifru_addr;
|
||||
struct sockaddr ifru_netmask;
|
||||
struct sockaddr ifru_gwaddr;
|
||||
struct sockaddr ifru_hwaddr;
|
||||
unsigned char __min_storage[sizeof(sockaddr) + 6];
|
||||
} ifr_ifru;
|
||||
};
|
||||
|
||||
#define SIOCGIFADDR 1 /* Get interface address */
|
||||
#define SIOCSIFADDR 2 /* Set interface address */
|
||||
#define SIOCGIFNETMASK 3 /* Get network mask */
|
||||
#define SIOCSIFNETMASK 4 /* Set network mask */
|
||||
#define SIOCGIFGWADDR 5 /* Get gateway address */
|
||||
#define SIOCSIFGWADDR 6 /* Set gateway address */
|
||||
#define SIOCGIFHWADDR 7 /* Get hardware address */
|
||||
|
||||
void if_freenameindex(struct if_nameindex* ptr);
|
||||
char* if_indextoname(unsigned ifindex, char* ifname);
|
||||
struct if_nameindex* if_nameindex(void);
|
||||
unsigned if_nametoindex(const char* ifname);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
112
userspace/libraries/LibC/include/netdb.h
Normal file
112
userspace/libraries/LibC/include/netdb.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef _NETDB_H
|
||||
#define _NETDB_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netdb.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define IPPORT_RESERVED 1024
|
||||
|
||||
#define AI_PASSIVE 0x01
|
||||
#define AI_CANONNAME 0x02
|
||||
#define AI_NUMERICHOST 0x04
|
||||
#define AI_NUMERICSERV 0x08
|
||||
#define AI_V4MAPPED 0x10
|
||||
#define AI_ALL 0x20
|
||||
#define AI_ADDRCONFIG 0x40
|
||||
|
||||
#define NI_NOFQDN 0x01
|
||||
#define NI_NUMERICHOST 0x02
|
||||
#define NI_NAMEREQD 0x04
|
||||
#define NI_NUMERICSERV 0x08
|
||||
#define NI_NUMERICSCOPE 0x10
|
||||
#define NI_DGRAM 0x20
|
||||
|
||||
#define EAI_AGAIN 1
|
||||
#define EAI_BADFLAGS 2
|
||||
#define EAI_FAIL 3
|
||||
#define EAI_FAMILY 4
|
||||
#define EAI_MEMORY 5
|
||||
#define EAI_NONAME 6
|
||||
#define EAI_SERVICE 7
|
||||
#define EAI_SOCKTYPE 8
|
||||
#define EAI_SYSTEM 9
|
||||
#define EAI_OVERFLOW 10
|
||||
|
||||
struct hostent
|
||||
{
|
||||
char* h_name; /* Official name of the host. */
|
||||
char** h_aliases; /* A pointer to an array of pointers to alternative host names, terminated by a null pointer. */
|
||||
int h_addrtype; /* Address type. */
|
||||
int h_length; /* The length, in bytes, of the address. */
|
||||
char** h_addr_list; /* A pointer to an array of pointers to network addresses (in network byte order) for the host, terminated by a null pointer. */
|
||||
};
|
||||
|
||||
struct netent
|
||||
{
|
||||
char* n_name; /* Official, fully-qualified (including the domain) name of the host. */
|
||||
char** n_aliases; /* A pointer to an array of pointers to alternative network names, terminated by a null pointer. */
|
||||
int n_addrtype; /* The address type of the network. */
|
||||
uint32_t n_net; /* The network number, in host byte order. */
|
||||
};
|
||||
|
||||
struct protoent
|
||||
{
|
||||
char* p_name; /* Official name of the protocol. */
|
||||
char** p_aliases; /* A pointer to an array of pointers to alternative protocol names, terminated by a null pointer. */
|
||||
int p_proto; /* The protocol number. */
|
||||
};
|
||||
|
||||
struct servent
|
||||
{
|
||||
char* s_name; /* Official name of the service. */
|
||||
char** s_aliases; /* A pointer to an array of pointers to alternative service names, terminated by a null pointer. */
|
||||
int s_port; /* A value which, when converted to uint16_t, yields the port number in network byte order at which the service resides. */
|
||||
char* s_proto; /* The name of the protocol to use when contacting the service. */
|
||||
};
|
||||
|
||||
struct addrinfo
|
||||
{
|
||||
int ai_flags; /* Input flags. */
|
||||
int ai_family; /* Address family of socket. */
|
||||
int ai_socktype; /* Socket type. */
|
||||
int ai_protocol; /* Protocol of socket. */
|
||||
socklen_t ai_addrlen; /* Length of socket address. */
|
||||
struct sockaddr* ai_addr; /* Socket address of socket. */
|
||||
char* ai_canonname; /* Canonical name of service location. */
|
||||
struct addrinfo* ai_next; /* Pointer to next in list. */
|
||||
};
|
||||
|
||||
void endhostent(void);
|
||||
void endnetent(void);
|
||||
void endprotoent(void);
|
||||
void endservent(void);
|
||||
void freeaddrinfo(struct addrinfo* ai);
|
||||
const char* gai_strerror(int ecode);
|
||||
int getaddrinfo(const char* __restrict nodename, const char* __restrict servname, const struct addrinfo* __restrict hints, struct addrinfo** __restrict res);
|
||||
struct hostent* gethostbyname(const char* name);
|
||||
struct hostent* gethostent(void);
|
||||
int getnameinfo(const struct sockaddr* __restrict sa, socklen_t salen, char* __restrict node, socklen_t nodelen, char* __restrict service, socklen_t servicelen, int flags);
|
||||
struct netent* getnetbyaddr(uint32_t net, int type);
|
||||
struct netent* getnetbyname(const char* name);
|
||||
struct netent* getnetent(void);
|
||||
struct protoent* getprotobyname(const char* name);
|
||||
struct protoent* getprotobynumber(int proto);
|
||||
struct protoent* getprotoent(void);
|
||||
struct servent* getservbyname(const char* name, const char* proto);
|
||||
struct servent* getservbyport(int port, const char* proto);
|
||||
struct servent* getservent(void);
|
||||
void sethostent(int stayopen);
|
||||
void setnetent(int stayopen);
|
||||
void setprotoent(int stayopen);
|
||||
void setservent(int stayopen);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
92
userspace/libraries/LibC/include/netinet/in.h
Normal file
92
userspace/libraries/LibC/include/netinet/in.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#ifndef _NETINET_IN_H
|
||||
#define _NETINET_IN_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define IPPROTO_IP 1
|
||||
#define IPPROTO_IPV6 2
|
||||
#define IPPROTO_ICMP 3
|
||||
#define IPPROTO_RAW 4
|
||||
#define IPPROTO_TCP 5
|
||||
#define IPPROTO_UDP 6
|
||||
|
||||
#define IPV6_JOIN_GROUP 1
|
||||
#define IPV6_LEAVE_GROUP 2
|
||||
#define IPV6_MULTICAST_HOPS 3
|
||||
#define IPV6_MULTICAST_IF 4
|
||||
#define IPV6_MULTICAST_LOOP 5
|
||||
#define IPV6_UNICAST_HOPS 6
|
||||
#define IPV6_V6ONLY 7
|
||||
|
||||
#define INADDR_ANY 0
|
||||
#define INADDR_BROADCAST UINT32_MAX
|
||||
|
||||
#define INET_ADDRSTRLEN 16
|
||||
#define INET6_ADDRSTRLEN 46
|
||||
|
||||
#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
|
||||
#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
|
||||
|
||||
#if 0
|
||||
#define IN6_IS_ADDR_UNSPECIFIED(addr)
|
||||
#define IN6_IS_ADDR_LOOPBACK(addr)
|
||||
#define IN6_IS_ADDR_MULTICAST(addr)
|
||||
#define IN6_IS_ADDR_LINKLOCAL(addr)
|
||||
#define IN6_IS_ADDR_SITELOCAL(addr)
|
||||
#define IN6_IS_ADDR_V4MAPPED(addr)
|
||||
#define IN6_IS_ADDR_V4COMPAT(addr)
|
||||
#define IN6_IS_ADDR_MC_NODELOCAL(addr)
|
||||
#define IN6_IS_ADDR_MC_LINKLOCAL(addr)
|
||||
#define IN6_IS_ADDR_MC_SITELOCAL(addr)
|
||||
#define IN6_IS_ADDR_MC_ORGLOCAL(addr)
|
||||
#define IN6_IS_ADDR_MC_GLOBAL(addr)
|
||||
#endif
|
||||
|
||||
typedef uint16_t in_port_t;
|
||||
typedef uint32_t in_addr_t;
|
||||
|
||||
struct in_addr
|
||||
{
|
||||
in_addr_t s_addr;
|
||||
};
|
||||
|
||||
struct sockaddr_in
|
||||
{
|
||||
sa_family_t sin_family; /* AF_INET. */
|
||||
in_port_t sin_port; /* Port number. */
|
||||
struct in_addr sin_addr; /* IP address. */
|
||||
};
|
||||
|
||||
struct in6_addr
|
||||
{
|
||||
uint8_t s6_addr[16];
|
||||
};
|
||||
|
||||
struct sockaddr_in6
|
||||
{
|
||||
sa_family_t sin6_family; /* AF_INET6. */
|
||||
in_port_t sin6_port; /* Port number. */
|
||||
uint32_t sin6_flowinfo; /* IPv6 traffic class and flow information. */
|
||||
struct in6_addr sin6_addr; /* IPv6 address. */
|
||||
uint32_t sin6_scope_id; /* Set of interfaces for a scope. */
|
||||
};
|
||||
|
||||
extern const struct in6_addr in6addr_any;
|
||||
extern const struct in6_addr in6addr_loopback;
|
||||
|
||||
struct ipv6_mreq
|
||||
{
|
||||
struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast address. */
|
||||
unsigned ipv6mr_interface; /* Interface index. */
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
14
userspace/libraries/LibC/include/netinet/tcp.h
Normal file
14
userspace/libraries/LibC/include/netinet/tcp.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __NETINET_TCP_H
|
||||
#define __NETINET_TCP_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_tcp.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define TCP_NODELAY 1
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
22
userspace/libraries/LibC/include/nl_types.h
Normal file
22
userspace/libraries/LibC/include/nl_types.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef _NL_TYPES_H
|
||||
#define _NL_TYPES_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/nl_types.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef void* nl_catd;
|
||||
typedef int nl_item;
|
||||
|
||||
#define NL_SETD 1
|
||||
#define NL_CAT_LOCALE 1
|
||||
|
||||
int charclose(nl_catd catd);
|
||||
char* catgets(nl_catd catd, int set_id, int msg_id, const char* s);
|
||||
nl_catd catopen(const char* name, int oflag);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
34
userspace/libraries/LibC/include/poll.h
Normal file
34
userspace/libraries/LibC/include/poll.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _POLL_H
|
||||
#define _POLL_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/poll.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct pollfd
|
||||
{
|
||||
int fd; /* The following descriptor being polled. */
|
||||
short events; /* The input event flags. */
|
||||
short revents; /* The output event flags. */
|
||||
};
|
||||
|
||||
typedef unsigned long nfds_t;
|
||||
|
||||
#define POLLIN 0x001
|
||||
#define POLLRDNORM 0x002
|
||||
#define POLLRDBAND 0x004
|
||||
#define POLLPRI 0x008
|
||||
#define POLLOUT 0x010
|
||||
#define POLLWRNORM 0x020
|
||||
#define POLLWRBAND 0x040
|
||||
#define POLLERR 0x080
|
||||
#define POLLHUP 0x100
|
||||
#define POLLNVAL 0x200
|
||||
|
||||
int poll(struct pollfd fds[], nfds_t nfds, int timeout);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
165
userspace/libraries/LibC/include/pthread.h
Normal file
165
userspace/libraries/LibC/include/pthread.h
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef _PTHREAD_H
|
||||
#define _PTHREAD_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pthread.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <sched.h>
|
||||
#include <time.h>
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_clockid_t
|
||||
#define __need_pthread_attr_t
|
||||
#define __need_pthread_barrier_t
|
||||
#define __need_pthread_barrierattr_t
|
||||
#define __need_pthread_cond_t
|
||||
#define __need_pthread_condattr_t
|
||||
#define __need_pthread_key_t
|
||||
#define __need_pthread_mutex_t
|
||||
#define __need_pthread_mutexattr_t
|
||||
#define __need_pthread_once_t
|
||||
#define __need_pthread_rwlock_t
|
||||
#define __need_pthread_rwlockattr_t
|
||||
#define __need_pthread_spinlock_t
|
||||
#define __need_pthread_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#define PTHREAD_BARRIER_SERIAL_THREAD 1
|
||||
#define PTHREAD_CANCEL_ASYNCHRONOUS 2
|
||||
#define PTHREAD_CANCEL_ENABLE 3
|
||||
#define PTHREAD_CANCEL_DEFERRED 4
|
||||
#define PTHREAD_CANCEL_DISABLE 5
|
||||
#define PTHREAD_CANCELED 6
|
||||
#define PTHREAD_CREATE_DETACHED 7
|
||||
#define PTHREAD_CREATE_JOINABLE 8
|
||||
#define PTHREAD_EXPLICIT_SCHED 9
|
||||
#define PTHREAD_INHERIT_SCHED 10
|
||||
#define PTHREAD_MUTEX_DEFAULT 11
|
||||
#define PTHREAD_MUTEX_ERRORCHECK 12
|
||||
#define PTHREAD_MUTEX_NORMAL 13
|
||||
#define PTHREAD_MUTEX_RECURSIVE 14
|
||||
#define PTHREAD_MUTEX_ROBUST 15
|
||||
#define PTHREAD_MUTEX_STALLED 16
|
||||
#define PTHREAD_ONCE_INIT 17
|
||||
#define PTHREAD_PRIO_INHERIT 18
|
||||
#define PTHREAD_PRIO_NONE 19
|
||||
#define PTHREAD_PRIO_PROTECT 20
|
||||
#define PTHREAD_PROCESS_SHARED 21
|
||||
#define PTHREAD_PROCESS_PRIVATE 22
|
||||
#define PTHREAD_SCOPE_PROCESS 23
|
||||
#define PTHREAD_SCOPE_SYSTEM 24
|
||||
|
||||
#if 0
|
||||
#define PTHREAD_COND_INITIALIZER
|
||||
#define PTHREAD_MUTEX_INITIALIZER
|
||||
#define PTHREAD_RWLOCK_INITIALIZER
|
||||
#endif
|
||||
|
||||
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void(*child)(void));
|
||||
int pthread_attr_destroy(pthread_attr_t* attr);
|
||||
int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detachstate);
|
||||
int pthread_attr_getguardsize(const pthread_attr_t* __restrict attr, size_t* __restrict guardsize);
|
||||
int pthread_attr_getinheritsched(const pthread_attr_t* __restrict attr, int* __restrict inheritsched);
|
||||
int pthread_attr_getschedparam(const pthread_attr_t* __restrict attr, struct sched_param* __restrict param);
|
||||
int pthread_attr_getschedpolicy(const pthread_attr_t* __restrict attr, int* __restrict policy);
|
||||
int pthread_attr_getscope(const pthread_attr_t* __restrict attr, int* __restrict contentionscope);
|
||||
int pthread_attr_getstack(const pthread_attr_t* __restrict attr, void** __restrict stackaddr, size_t* __restrict stacksize);
|
||||
int pthread_attr_getstacksize(const pthread_attr_t* __restrict attr, size_t* __restrict stacksize);
|
||||
int pthread_attr_init(pthread_attr_t* attr);
|
||||
int pthread_attr_setdetachstate(pthread_attr_t* attr, int detachstate);
|
||||
int pthread_attr_setguardsize(pthread_attr_t* attr, size_t guardsize);
|
||||
int pthread_attr_setinheritsched(pthread_attr_t* attr, int inheritsched);
|
||||
int pthread_attr_setschedparam(pthread_attr_t* __restrict attr, const struct sched_param* __restrict param);
|
||||
int pthread_attr_setschedpolicy(pthread_attr_t* attr, int policy);
|
||||
int pthread_attr_setscope(pthread_attr_t* attr, int contentionscope);
|
||||
int pthread_attr_setstack(pthread_attr_t* attr, void* stackaddr, size_t stacksize);
|
||||
int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stacksize);
|
||||
int pthread_barrier_destroy(pthread_barrier_t* barrier);
|
||||
int pthread_barrier_init(pthread_barrier_t* __restrict barrier, const pthread_barrierattr_t* __restrict attr, unsigned count);
|
||||
int pthread_barrier_wait(pthread_barrier_t* barrier);
|
||||
int pthread_barrierattr_destroy(pthread_barrierattr_t* attr);
|
||||
int pthread_barrierattr_getpshared( const pthread_barrierattr_t* __restrict attr, int* __restrict pshared);
|
||||
int pthread_barrierattr_init(pthread_barrierattr_t* attr);
|
||||
int pthread_barrierattr_setpshared(pthread_barrierattr_t* attr, int pshared);
|
||||
int pthread_cancel(pthread_t thread);
|
||||
int pthread_cond_broadcast(pthread_cond_t* cond);
|
||||
int pthread_cond_destroy(pthread_cond_t* cond);
|
||||
int pthread_cond_init(pthread_cond_t* __restrict cond, const pthread_condattr_t* __restrict attr);
|
||||
int pthread_cond_signal(pthread_cond_t* cond);
|
||||
int pthread_cond_timedwait(pthread_cond_t* __restrict cond, pthread_mutex_t* __restrict mutex, const struct timespec* __restrict abstime);
|
||||
int pthread_cond_wait(pthread_cond_t* __restrict cond, pthread_mutex_t* __restrict mutex);
|
||||
int pthread_condattr_destroy(pthread_condattr_t* attr);
|
||||
int pthread_condattr_getclock(const pthread_condattr_t* __restrict attr, clockid_t* __restrict clock_id);
|
||||
int pthread_condattr_getpshared(const pthread_condattr_t* __restrict attr, int* __restrict pshared);
|
||||
int pthread_condattr_init(pthread_condattr_t* attr);
|
||||
int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock_id);
|
||||
int pthread_condattr_setpshared(pthread_condattr_t* attr, int pshared);
|
||||
int pthread_create(pthread_t* __restrict thread, const pthread_attr_t* __restrict attr, void *(*start_routine)(void*), void* __restrict arg);
|
||||
int pthread_detach(pthread_t thread);
|
||||
int pthread_equal(pthread_t t1, pthread_t t2);
|
||||
void pthread_exit(void* value_ptr);
|
||||
int pthread_getconcurrency(void);
|
||||
int pthread_getcpuclockid(pthread_t thread_id, clockid_t* clock_id);
|
||||
int pthread_getschedparam(pthread_t thread, int* __restrict policy, struct sched_param* __restrict param);
|
||||
void* pthread_getspecific(pthread_key_t key);
|
||||
int pthread_join(pthread_t thread, void** value_ptr);
|
||||
int pthread_key_create(pthread_key_t* key, void (*destructor)(void*));
|
||||
int pthread_key_delete(pthread_key_t key);
|
||||
int pthread_mutex_consistent(pthread_mutex_t* mutex);
|
||||
int pthread_mutex_destroy(pthread_mutex_t* mutex);
|
||||
int pthread_mutex_getprioceiling(const pthread_mutex_t* __restrict mutex, int* __restrict prioceiling);
|
||||
int pthread_mutex_init(pthread_mutex_t* __restrict mutex, const pthread_mutexattr_t* __restrict attr);
|
||||
int pthread_mutex_lock(pthread_mutex_t* mutex);
|
||||
int pthread_mutex_setprioceiling(pthread_mutex_t* __restrict mutex, int prioceiling, int* __restrict old_ceiling);
|
||||
int pthread_mutex_timedlock(pthread_mutex_t* __restrict mutex, const struct timespec* __restrict abstime);
|
||||
int pthread_mutex_trylock(pthread_mutex_t* mutex);
|
||||
int pthread_mutex_unlock(pthread_mutex_t* mutex);
|
||||
int pthread_mutexattr_destroy(pthread_mutexattr_t* attr);
|
||||
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t* __restrict attr, int* __restrict prioceiling);
|
||||
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t* __restrict attr, int* __restrict protocol);
|
||||
int pthread_mutexattr_getpshared(const pthread_mutexattr_t* __restrict attr, int* __restrict pshared);
|
||||
int pthread_mutexattr_getrobust(const pthread_mutexattr_t* __restrict attr, int* __restrict robust);
|
||||
int pthread_mutexattr_gettype(const pthread_mutexattr_t* __restrict attr, int* __restrict type);
|
||||
int pthread_mutexattr_init(pthread_mutexattr_t* attr);
|
||||
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t* attr, int prioceiling);
|
||||
int pthread_mutexattr_setprotocol(pthread_mutexattr_t* attr, int protocol);
|
||||
int pthread_mutexattr_setpshared(pthread_mutexattr_t* attr, int pshared);
|
||||
int pthread_mutexattr_setrobust(pthread_mutexattr_t* attr, int robust);
|
||||
int pthread_mutexattr_settype(pthread_mutexattr_t* attr, int type);
|
||||
int pthread_once(pthread_once_t* once_control, void (*init_routine)(void));
|
||||
int pthread_rwlock_destroy(pthread_rwlock_t* rwlock);
|
||||
int pthread_rwlock_init(pthread_rwlock_t* __restrict rwlock, const pthread_rwlockattr_t* __restrict attr);
|
||||
int pthread_rwlock_rdlock(pthread_rwlock_t* rwlock);
|
||||
int pthread_rwlock_timedrdlock(pthread_rwlock_t* __restrict rwlock, const struct timespec* __restrict abstime);
|
||||
int pthread_rwlock_timedwrlock(pthread_rwlock_t* __restrict rwlock, const struct timespec* __restrict abstime);
|
||||
int pthread_rwlock_tryrdlock(pthread_rwlock_t* rwlock);
|
||||
int pthread_rwlock_trywrlock(pthread_rwlock_t* rwlock);
|
||||
int pthread_rwlock_unlock(pthread_rwlock_t* rwlock);
|
||||
int pthread_rwlock_wrlock(pthread_rwlock_t* rwlock);
|
||||
int pthread_rwlockattr_destroy(pthread_rwlockattr_t* attr);
|
||||
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t* __restrict attr, int* __restrict pshared);
|
||||
int pthread_rwlockattr_init(pthread_rwlockattr_t* attr);
|
||||
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t* attr, int pshared);
|
||||
pthread_t pthread_self(void);
|
||||
int pthread_setcancelstate(int state, int* oldstate);
|
||||
int pthread_setcanceltype(int type, int* oldtype);
|
||||
int pthread_setconcurrency(int new_level);
|
||||
int pthread_setschedparam(pthread_t thread, int policy, const struct sched_param* param);
|
||||
int pthread_setschedprio(pthread_t thread, int prio);
|
||||
int pthread_setspecific(pthread_key_t key, const void* value);
|
||||
int pthread_spin_destroy(pthread_spinlock_t* lock);
|
||||
int pthread_spin_init(pthread_spinlock_t* lock, int pshared);
|
||||
int pthread_spin_lock(pthread_spinlock_t* lock);
|
||||
int pthread_spin_trylock(pthread_spinlock_t* lock);
|
||||
int pthread_spin_unlock(pthread_spinlock_t* lock);
|
||||
void pthread_testcancel(void);
|
||||
|
||||
void pthread_cleanup_pop(int execute);
|
||||
void pthread_cleanup_push(void (*routine)(void*), void* arg);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
34
userspace/libraries/LibC/include/pwd.h
Normal file
34
userspace/libraries/LibC/include/pwd.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _PWD_H
|
||||
#define _PWD_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pwd.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_gid_t
|
||||
#define __need_uid_t
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct passwd
|
||||
{
|
||||
char* pw_name; /* User's login name. */
|
||||
uid_t pw_uid; /* Numerical user ID. */
|
||||
gid_t pw_gid; /* Numerical group ID. */
|
||||
char* pw_dir; /* Initial working directory. */
|
||||
char* pw_shell; /* Program to use as shell. */
|
||||
};
|
||||
|
||||
void endpwent(void);
|
||||
struct passwd* getpwent(void);
|
||||
struct passwd* getpwnam(const char* name);
|
||||
int getpwnam_r(const char* name, struct passwd* pwd, char* buffer, size_t bufsize, struct passwd** result);
|
||||
struct passwd* getpwuid(uid_t uid);
|
||||
int getpwuid_r(uid_t uid, struct passwd* pwd, char* buffer, size_t bufsize, struct passwd** result);
|
||||
void setpwent(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
54
userspace/libraries/LibC/include/regex.h
Normal file
54
userspace/libraries/LibC/include/regex.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef _REGEX_H
|
||||
#define _REGEX_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/regex.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t re_nsub;
|
||||
} regex_t;
|
||||
|
||||
typedef __PTRDIFF_TYPE__ regoff_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
regoff_t rm_so; /* Byte offset from start of string to start of substring. */
|
||||
regoff_t rm_eo; /* Byte offset from start of string of the first character after the end of substring. */
|
||||
} regmatch_t;
|
||||
|
||||
#define REG_EXTENDED 0x01
|
||||
#define REG_ICASE 0x02
|
||||
#define REG_NOSUB 0x04
|
||||
#define REG_NEWLINE 0x80
|
||||
|
||||
#define REG_NOTBOL 0x0001
|
||||
#define REG_NOTEOL 0x0002
|
||||
#define REG_NOMATCH 0x0004
|
||||
#define REG_BADPAT 0x0008
|
||||
#define REG_ECOLLATE 0x0010
|
||||
#define REG_ECTYPE 0x0020
|
||||
#define REG_EESCAPE 0x0040
|
||||
#define REG_ESUBREG 0x0080
|
||||
#define REG_EBRACK 0x0100
|
||||
#define REG_EPAREN 0x0200
|
||||
#define REG_EBRACE 0x0400
|
||||
#define REG_BADBR 0x0800
|
||||
#define REG_ERANGE 0x1000
|
||||
#define REG_ESPACE 0x2000
|
||||
#define REG_BADRPT 0x4000
|
||||
|
||||
int regcomp(regex_t* __restrict preg, const char* __restrict pattern, int cflags);
|
||||
size_t regerror(int errcode, const regex_t* __restrict preg, char* __restrict errbuf, size_t errbuf_size);
|
||||
int regexec(const regex_t* __restrict preg, const char* __restrict string, size_t nmatch, regmatch_t pmatch[__restrict], int eflags);
|
||||
void regfree(regex_t* preg);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
5
userspace/libraries/LibC/include/scanf_impl.h
Normal file
5
userspace/libraries/LibC/include/scanf_impl.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int scanf_impl(const char* format, va_list arguments, int (*getc_fun)(void*), void* data);
|
||||
40
userspace/libraries/LibC/include/sched.h
Normal file
40
userspace/libraries/LibC/include/sched.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef _SCHED_H
|
||||
#define _SCHED_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sched.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct sched_param
|
||||
{
|
||||
int sched_priority; /* Process or thread execution scheduling priority. */
|
||||
int sched_ss_low_priority; /* Low scheduling priority for sporadic server. */
|
||||
struct timespec sched_ss_repl_period; /* Replenishment period for sporadic server. */
|
||||
struct timespec sched_ss_init_budget; /* Initial budget for sporadic server. */
|
||||
int sched_ss_max_repl; /* Maximum pending replenishments for sporadic server. */
|
||||
};
|
||||
|
||||
#define SCHED_FIFO 1
|
||||
#define SCHED_RR 2
|
||||
#define SCHED_SPORADIC 3
|
||||
#define SCHED_OTHER 4
|
||||
|
||||
int sched_get_priority_max(int policy);
|
||||
int sched_get_priority_min(int policy);
|
||||
int sched_getparam(pid_t pid, struct sched_param* param);
|
||||
int sched_getscheduler(pid_t pid);
|
||||
int sched_rr_get_interval(pid_t pid, struct timespec* interval);
|
||||
int sched_setparam(pid_t pid, const struct sched_param* param);
|
||||
int sched_setscheduler(pid_t pid, int, const struct sched_param* param);
|
||||
int sched_yield(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
36
userspace/libraries/LibC/include/search.h
Normal file
36
userspace/libraries/LibC/include/search.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef _SEARCH_H
|
||||
#define _SEARCH_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/search.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char* key;
|
||||
void* data;
|
||||
} ENTRY;
|
||||
|
||||
typedef enum { FIND, ENTER } ACTION;
|
||||
typedef enum { preorder, postorder, endorder, leaf } VISIT;
|
||||
|
||||
int hcreate(size_t nel);
|
||||
void hdestroy(void);
|
||||
ENTRY* hsearch(ENTRY item, ACTION action);
|
||||
void insque(void* element, void* pred);
|
||||
void* lfind(const void* key, const void* base, size_t* nelp, size_t width, int (*compar)(const void*, const void*));
|
||||
void* lsearch(const void* key, void* base, size_t* nelp, size_t width, int (*compar)(const void*, const void*));
|
||||
void remque(void* element);
|
||||
void* tdelete(const void* __restrict key, void** __restrict rootp, int(*compar)(const void*, const void*));
|
||||
void* tfind(const void* key, void* const* rootp, int(*compar)(const void*, const void*));
|
||||
void* tsearch(const void* key, void** rootp, int(*compar)(const void*, const void*));
|
||||
void twalk(const void* root, void (*action)(const void*, VISIT, int));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
30
userspace/libraries/LibC/include/semaphore.h
Normal file
30
userspace/libraries/LibC/include/semaphore.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _SEMAPHORE_H
|
||||
#define _SEMAPHORE_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/semaphore.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
|
||||
typedef void* sem_t;
|
||||
|
||||
#define SEM_FAILED ((sem_t*)0)
|
||||
|
||||
int sem_close(sem_t* sem);
|
||||
int sem_destroy(sem_t* sem);
|
||||
int sem_getvalue(sem_t* __restrict sem, int* __restrict sval);
|
||||
int sem_init(sem_t* sem, int pshared, unsigned value);
|
||||
sem_t* sem_open(const char* name, int oflag, ...);
|
||||
int sem_post(sem_t* sem);
|
||||
int sem_timedwait(sem_t* __restrict sem, const struct timespec* __restrict abstime);
|
||||
int sem_trywait(sem_t* sem);
|
||||
int sem_unlink(const char* name);
|
||||
int sem_wait(sem_t* sem);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
20
userspace/libraries/LibC/include/setjmp.h
Normal file
20
userspace/libraries/LibC/include/setjmp.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _SETJMP_H
|
||||
#define _SETJMP_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/setjmp.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef int jmp_buf[1];
|
||||
typedef int sigjmp_buf[1];
|
||||
|
||||
void longjmp(jmp_buf env, int val);
|
||||
void siglongjmp(sigjmp_buf env, int val);
|
||||
int setjmp(jmp_buf env);
|
||||
int sigsetjmp(sigjmp_buf env, int savemask);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
170
userspace/libraries/LibC/include/signal.h
Normal file
170
userspace/libraries/LibC/include/signal.h
Normal file
@@ -0,0 +1,170 @@
|
||||
#ifndef _SIGNAL_H
|
||||
#define _SIGNAL_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#define SIG_DFL ((void (*)(int))0)
|
||||
#define SIG_ERR ((void (*)(int))1)
|
||||
#define SIG_HOLD ((void (*)(int))2)
|
||||
#define SIG_IGN ((void (*)(int))3)
|
||||
|
||||
#define __need_pthread_t
|
||||
#define __need_size_t
|
||||
#define __need_uid_t
|
||||
#define __need_pid_t
|
||||
#define __need_pthread_attr_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef int sig_atomic_t;
|
||||
typedef void* sigset_t;
|
||||
|
||||
union sigval
|
||||
{
|
||||
int sival_int; /* Integer signal value. */
|
||||
void* sival_ptr; /* Pointer signal value. */
|
||||
};
|
||||
|
||||
struct sigevent
|
||||
{
|
||||
int sigev_notify; /* Notification type. */
|
||||
int sigev_signo; /* Signal number. */
|
||||
union sigval sigev_value; /* Signal value. */
|
||||
void (*sigev_notify_function)(union sigval); /* Notification function. */
|
||||
pthread_attr_t* sigev_notify_attributes; /* Notification attributes. */
|
||||
};
|
||||
|
||||
#define SIGEV_NONE 1
|
||||
#define SIGEV_SIGNAL 2
|
||||
#define SIGEV_THREAD 3
|
||||
|
||||
#define SIGABRT 1
|
||||
#define SIGALRM 2
|
||||
#define SIGBUS 3
|
||||
#define SIGCHLD 4
|
||||
#define SIGCONT 5
|
||||
#define SIGFPE 6
|
||||
#define SIGHUP 7
|
||||
#define SIGILL 8
|
||||
#define SIGINT 9
|
||||
#define SIGKILL 10
|
||||
#define SIGPIPE 11
|
||||
#define SIGQUIT 12
|
||||
#define SIGSEGV 13
|
||||
#define SIGSTOP 14
|
||||
#define SIGTERM 15
|
||||
#define SIGTSTP 16
|
||||
#define SIGTTIN 17
|
||||
#define SIGTTOU 18
|
||||
#define SIGUSR1 19
|
||||
#define SIGUSR2 20
|
||||
#define SIGPOLL 21
|
||||
#define SIGPROF 22
|
||||
#define SIGSYS 23
|
||||
#define SIGTRAP 24
|
||||
#define SIGURG 25
|
||||
#define SIGVTALRM 26
|
||||
#define SIGXCPU 27
|
||||
#define SIGXFSZ 28
|
||||
#define SIGRTMIN 29
|
||||
#define SIGRTMAX (SIGRTMIN+32)
|
||||
|
||||
#define _SIGMIN SIGABRT
|
||||
#define _SIGMAX SIGRTMAX
|
||||
|
||||
#define SIG_BLOCK 1
|
||||
#define SIG_UNBLOCK 2
|
||||
#define SIG_SETMASK 3
|
||||
|
||||
#define SA_NOCLDSTOP 0x001
|
||||
#define SA_ONSTACK 0x002
|
||||
#define SA_RESETHAND 0x004
|
||||
#define SA_RESTART 0x008
|
||||
#define SA_SIGINFO 0x010
|
||||
#define SA_NOCLDWAIT 0x020
|
||||
#define SA_NODEFER 0x040
|
||||
#define SS_ONSTACK 0x080
|
||||
#define SS_DISABLE 0x100
|
||||
#define MINSIGSTKSZ 0x200
|
||||
#define SIGSTKSZ 0x400
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void** ss_sp; /* Stack base or pointer. */
|
||||
size_t ss_size; /* Stack size. */
|
||||
int ss_flags; /* Flags. */
|
||||
} stack_t;
|
||||
|
||||
typedef struct {} mcontext_t;
|
||||
|
||||
typedef struct __ucontext_t
|
||||
{
|
||||
struct __ucontext_t* uc_link; /* Pointer to the context that is resumed when this context returns. */
|
||||
sigset_t uc_sigmask; /* The set of signals that are blocked when this context is active. */
|
||||
stack_t uc_stack; /* The stack used by this context. */
|
||||
mcontext_t uc_mcontext; /* A machine-specific representation of the saved context. */
|
||||
} ucontext_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int si_signo; /* Signal number. */
|
||||
int si_code; /* Signal code. */
|
||||
int si_errno; /* If non-zero, an errno value associated with this signal, as described in <errno.h>. */
|
||||
pid_t si_pid; /* Sending process ID. */
|
||||
uid_t si_uid; /* Real user ID of sending process. */
|
||||
void* si_addr; /* Address of faulting instruction. */
|
||||
int si_status; /* Exit value or signal. */
|
||||
long si_band; /* Band event for SIGPOLL. */
|
||||
union sigval si_value; /* Signal value. */
|
||||
} siginfo_t;
|
||||
|
||||
struct sigaction
|
||||
{
|
||||
void (*sa_handler)(int); /* Pointer to a signal-catching function or one of the SIG_IGN or SIG_DFL. */
|
||||
sigset_t sa_mask; /* Set of signals to be blocked during execution of the signal handling function. */
|
||||
int sa_flags; /* Special flags. */
|
||||
void (*sa_sigaction)(int, siginfo_t*, void*); /* Pointer to a signal-catching function. */
|
||||
};
|
||||
|
||||
// TODO: The <signal.h> header shall define the symbolic constants in the
|
||||
// Code column of the following table for use as values of si_code
|
||||
// that are signal-specific or non-signal-specific reasons why the
|
||||
// signal was generated.
|
||||
|
||||
int kill(pid_t pid, int sig);
|
||||
int killpg(pid_t pgpr, int sig);
|
||||
void psiginfo(const siginfo_t* pinfo, const char* message);
|
||||
void psignal(int signum, const char* message);
|
||||
int pthread_kill(pthread_t thread, int sig);
|
||||
int pthread_sigmask(int how, const sigset_t* __restrict set, sigset_t* __restrict oset);
|
||||
int raise(int sig);
|
||||
int sigaction(int sig, const struct sigaction* __restrict act, struct sigaction* __restrict oact);
|
||||
int sigaddset(sigset_t* set, int signo);
|
||||
int sigaltstack(const stack_t* __restrict ss, stack_t* __restrict oss);
|
||||
int sigdelset(sigset_t* set, int signo);
|
||||
int sigemptyset(sigset_t* set);
|
||||
int sigfillset(sigset_t* set);
|
||||
int sighold(int sig);
|
||||
int sigignore(int sig);
|
||||
int siginterrupt(int sig, int flag);
|
||||
int sigismember(const sigset_t* set, int signo);
|
||||
void (*signal(int sig, void (*func)(int)))(int);
|
||||
int sigpause(int sig);
|
||||
int sigpending(sigset_t* set);
|
||||
int sigprocmask(int how, const sigset_t* __restrict set, sigset_t* __restrict oset);
|
||||
int sigqueue(pid_t pid, int signo, union sigval value);
|
||||
int sigrelse(int sig);
|
||||
void (*sigset(int sig, void (*disp)(int)))(int);
|
||||
int sigsuspend(const sigset_t* sigmask);
|
||||
int sigtimedwait(const sigset_t* __restrict set, siginfo_t* __restrict info, const struct timespec* __restrict timeout);
|
||||
int sigwait(const sigset_t* __restrict set, int* __restrict sig);
|
||||
int sigwaitinfo(const sigset_t* __restrict set, siginfo_t* __restrict info);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
51
userspace/libraries/LibC/include/spawn.h
Normal file
51
userspace/libraries/LibC/include/spawn.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef _SPAWN_H
|
||||
#define _SPAWN_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/spawn.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define __need_mode_t
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef int posix_spawnattr_t;
|
||||
typedef int posix_spawn_file_actions_t;
|
||||
|
||||
#define POSIX_SPAWN_RESETIDS 0x01
|
||||
#define POSIX_SPAWN_SETPGROUP 0x02
|
||||
#define POSIX_SPAWN_SETSCHEDPARAM 0x04
|
||||
#define POSIX_SPAWN_SETSCHEDULER 0x08
|
||||
#define POSIX_SPAWN_SETSIGDEF 0x10
|
||||
#define POSIX_SPAWN_SETSIGMASK 0x20
|
||||
|
||||
int posix_spawn(pid_t* __restrict pid, const char* __restrict path, const posix_spawn_file_actions_t* file_actions, const posix_spawnattr_t* __restrict attrp, char* const argv[__restrict], char* const envp[__restrict]);
|
||||
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t* file_actions, int fildes);
|
||||
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t* file_actions, int fildes, int newfildes);
|
||||
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* __restrict file_actions, int fildes, const char* __restrict path, int oflag, mode_t mode);
|
||||
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t* file_actions);
|
||||
int posix_spawn_file_actions_init(posix_spawn_file_actions_t* file_actions);
|
||||
int posix_spawnattr_destroy(posix_spawnattr_t* attr);
|
||||
int posix_spawnattr_getflags(const posix_spawnattr_t* __restrict attr, short* __restrict flags);
|
||||
int posix_spawnattr_getpgroup(const posix_spawnattr_t* __restrict attr, pid_t* __restrict pgroup);
|
||||
int posix_spawnattr_getschedparam(const posix_spawnattr_t* __restrict attr, struct sched_param* __restrict schedparam);
|
||||
int posix_spawnattr_getschedpolicy(const posix_spawnattr_t* __restrict attr, int* __restrict schedpolicy);
|
||||
int posix_spawnattr_getsigdefault(const posix_spawnattr_t* __restrict attr, sigset_t* __restrict sigdefault);
|
||||
int posix_spawnattr_getsigmask(const posix_spawnattr_t* __restrict attr, sigset_t* __restrict sigmask);
|
||||
int posix_spawnattr_init(posix_spawnattr_t* attr);
|
||||
int posix_spawnattr_setflags(posix_spawnattr_t* attr, short flags);
|
||||
int posix_spawnattr_setpgroup(posix_spawnattr_t* attr, pid_t pgroup);
|
||||
int posix_spawnattr_setschedparam(posix_spawnattr_t* __restrict attr, const struct sched_param* __restrict schedparam);
|
||||
int posix_spawnattr_setschedpolicy(posix_spawnattr_t* attr, int schedpolicy);
|
||||
int posix_spawnattr_setsigdefault(posix_spawnattr_t* __restrict attr, const sigset_t* __restrict sigdefault);
|
||||
int posix_spawnattr_setsigmask(posix_spawnattr_t* __restrict attr, const sigset_t* __restrict sigmask);
|
||||
int posix_spawnp(pid_t* __restrict pid, const char* __restrict file, const posix_spawn_file_actions_t* file_actions, const posix_spawnattr_t* __restrict attrp, char* const argc[__restrict], char* const envp[__restrict]);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
117
userspace/libraries/LibC/include/stdint.h
Normal file
117
userspace/libraries/LibC/include/stdint.h
Normal file
@@ -0,0 +1,117 @@
|
||||
#ifndef _STDINT_H
|
||||
#define _STDINT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef __INT8_TYPE__ int8_t;
|
||||
typedef __INT16_TYPE__ int16_t;
|
||||
typedef __INT32_TYPE__ int32_t;
|
||||
typedef __INT64_TYPE__ int64_t;
|
||||
|
||||
typedef __UINT8_TYPE__ uint8_t;
|
||||
typedef __UINT16_TYPE__ uint16_t;
|
||||
typedef __UINT32_TYPE__ uint32_t;
|
||||
typedef __UINT64_TYPE__ uint64_t;
|
||||
|
||||
typedef __INT_LEAST8_TYPE__ int_least8_t;
|
||||
typedef __INT_LEAST16_TYPE__ int_least16_t;
|
||||
typedef __INT_LEAST32_TYPE__ int_least32_t;
|
||||
typedef __INT_LEAST64_TYPE__ int_least64_t;
|
||||
|
||||
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
|
||||
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
|
||||
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
|
||||
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
|
||||
|
||||
typedef __INT_FAST8_TYPE__ int_fast8_t;
|
||||
typedef __INT_FAST16_TYPE__ int_fast16_t;
|
||||
typedef __INT_FAST32_TYPE__ int_fast32_t;
|
||||
typedef __INT_FAST64_TYPE__ int_fast64_t;
|
||||
|
||||
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
|
||||
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
|
||||
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
|
||||
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
||||
|
||||
typedef __INTPTR_TYPE__ intptr_t;
|
||||
typedef __UINTPTR_TYPE__ uintptr_t;
|
||||
|
||||
// FIXME: is this the correct?
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
#define INT8_MIN (-INT8_MAX - 1)
|
||||
#define INT16_MIN (-INT16_MAX - 1)
|
||||
#define INT32_MIN (-INT32_MAX - 1)
|
||||
#define INT64_MIN (-INT64_MAX - 1)
|
||||
|
||||
#define INT8_MAX __INT8_MAX__
|
||||
#define INT16_MAX __INT16_MAX__
|
||||
#define INT32_MAX __INT32_MAX__
|
||||
#define INT64_MAX __INT64_MAX__
|
||||
|
||||
#define UINT8_MAX __UINT8_MAX__
|
||||
#define UINT16_MAX __UINT16_MAX__
|
||||
#define UINT32_MAX __UINT32_MAX__
|
||||
#define UINT64_MAX __UINT64_MAX__
|
||||
|
||||
#define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1)
|
||||
#define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1)
|
||||
#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)
|
||||
#define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1)
|
||||
|
||||
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
|
||||
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
|
||||
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
|
||||
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
|
||||
|
||||
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
|
||||
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
|
||||
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
|
||||
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
|
||||
|
||||
#define INT_FAST8_MIN (-INT_FAST8_MAX - 1)
|
||||
#define INT_FAST16_MIN (-INT_FAST16_MAX - 1)
|
||||
#define INT_FAST32_MIN (-INT_FAST32_MAX - 1)
|
||||
#define INT_FAST64_MIN (-INT_FAST64_MAX - 1)
|
||||
|
||||
#define INT_FAST8_MAX __INT_FAST8_MAX__
|
||||
#define INT_FAST16_MAX __INT_FAST16_MAX__
|
||||
#define INT_FAST32_MAX __INT_FAST32_MAX__
|
||||
#define INT_FAST64_MAX __INT_FAST64_MAX__
|
||||
|
||||
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
|
||||
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
|
||||
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
|
||||
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
|
||||
|
||||
#define INTPTR_MIN (-INTPTR_MAX - 1)
|
||||
#define INTPTR_MAX __INTPTR_MAX__
|
||||
#define UINTPTR_MAX __UINTPTR_MAX__
|
||||
|
||||
// FIXME: is this the correct?
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
#define PTRDIFF_MIN -65535
|
||||
#define PTRDIFF_MAX +65535
|
||||
|
||||
#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__
|
||||
#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
|
||||
|
||||
#define SIZE_MAX __SIZE_MAX__
|
||||
|
||||
#define WCHAR_MIN __WCHAR_MIN__
|
||||
#define WCHAR_MAX __WCHAR_MAX__
|
||||
|
||||
#define WINT_MIN __WINT_MIN__
|
||||
#define WINT_MAX __WINT_MAX__
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
130
userspace/libraries/LibC/include/stdio.h
Normal file
130
userspace/libraries/LibC/include/stdio.h
Normal file
@@ -0,0 +1,130 @@
|
||||
#ifndef _STDIO_H
|
||||
#define _STDIO_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdio.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_off_t
|
||||
#define __need_ssize_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef __va_list_defined
|
||||
#define __va_list_defined
|
||||
#define __need___va_list
|
||||
#include <stdarg.h>
|
||||
typedef __gnuc_va_list va_list;
|
||||
#endif
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#include <bits/types/FILE.h>
|
||||
|
||||
typedef off_t fpos_t;
|
||||
|
||||
#define BUFSIZ 1024
|
||||
#define L_ctermid 20
|
||||
#define L_tmpnam 20
|
||||
|
||||
#define _IOFBF 1
|
||||
#define _IOLBF 2
|
||||
#define _IONBF 3
|
||||
|
||||
// NOTE: also defined in fcntl.h
|
||||
#define SEEK_SET 1
|
||||
#define SEEK_CUR 2
|
||||
#define SEEK_END 3
|
||||
|
||||
#define FILENAME_MAX 256
|
||||
#define FOPEN_MAX 16
|
||||
#define TMP_MAX 10000
|
||||
|
||||
#define EOF (-1)
|
||||
|
||||
#define P_tmpdir "/tmp"
|
||||
|
||||
extern FILE* __stdin;
|
||||
#define stdin __stdin
|
||||
extern FILE* __stdout;
|
||||
#define stdout __stdout
|
||||
extern FILE* __stderr;
|
||||
#define stderr __stderr
|
||||
extern FILE* __stddbg;
|
||||
#define stddbg __stddbg
|
||||
|
||||
void clearerr(FILE* stream);
|
||||
char* ctermid(char* s);
|
||||
int dprintf(int fildes, const char* __restrict format, ...);
|
||||
int fclose(FILE* stream);
|
||||
FILE* fdopen(int fildes, const char* mode);
|
||||
int feof(FILE* stream);
|
||||
int ferror(FILE* stream);
|
||||
int fflush(FILE* stream);
|
||||
int fgetc(FILE* stream);
|
||||
int fgetpos(FILE* __restrict stream, fpos_t* __restrict pos);
|
||||
char* fgets(char* __restrict s, int n, FILE* __restrict stream);
|
||||
int fileno(FILE* stream);
|
||||
void flockfile(FILE* stream);
|
||||
FILE* fmemopen(void* __restrict buf, size_t size, const char* __restrict mode);
|
||||
FILE* fopen(const char* __restrict pathname, const char* __restrict mode);
|
||||
int fprintf(FILE* __restrict stream, const char* __restrict format, ...);
|
||||
int fputc(int c, FILE* stream);
|
||||
int fputs(const char* __restrict s, FILE* __restrict stream);
|
||||
size_t fread(void* __restrict buf, size_t size, size_t nitems, FILE* __restrict stream);
|
||||
FILE* freopen(const char* __restrict pathname, const char* __restrict mode, FILE* __restrict stream);
|
||||
int fscanf(FILE* __restrict stream, const char* __restrict format, ...);
|
||||
int fseek(FILE* stream, long offset, int whence);
|
||||
int fseeko(FILE* stream, off_t offset, int whence);
|
||||
int fsetpos(FILE* stream, const fpos_t* pos);
|
||||
long ftell(FILE* stream);
|
||||
off_t ftello(FILE* stream);
|
||||
int ftrylockfile(FILE* stream);
|
||||
void funlockfile(FILE* stream);
|
||||
size_t fwrite(const void* __restrict ptr, size_t size, size_t nitems, FILE* __restrict stream);
|
||||
int getc(FILE* stream);
|
||||
int getchar(void);
|
||||
int getc_unlocked(FILE* stream);
|
||||
int getchar_unlocked(void);
|
||||
ssize_t getdelim(char** __restrict lineptr, size_t* __restrict n, int delimeter, FILE* __restrict stream);
|
||||
ssize_t getline(char** __restrict lineptr, size_t* __restrict n, FILE* __restrict stream);
|
||||
char* gets(char* s);
|
||||
FILE* open_memstream(char** bufp, size_t* sizep);
|
||||
int pclose(FILE* stream);
|
||||
void perror(const char* s);
|
||||
FILE* popen(const char* command, const char* mode);
|
||||
int printf(const char* __restrict format, ...);
|
||||
int putc(int c, FILE* stream);
|
||||
int putchar(int c);
|
||||
int putc_unlocked(int c, FILE* stream);
|
||||
int putchar_unlocked(int c);
|
||||
int puts(const char* s);
|
||||
int remove(const char* path);
|
||||
int rename(const char* old, const char* _new);
|
||||
int renameat(int oldfd, const char* old, int newfd, const char* _new);
|
||||
void rewind(FILE* stream);
|
||||
int scanf(const char* __restrict format, ...);
|
||||
void setbuf(FILE* __restrict stream, char* __restrict buf);
|
||||
int setvbuf(FILE* __restrict stream, char* __restrict buf, int type, size_t size);
|
||||
int snprintf(char* __restrict s, size_t n, const char* __restrict format, ...);
|
||||
int sprintf(char* __restrict s, const char* __restrict format, ...);
|
||||
int sscanf(const char* __restrict s, const char* __restrict format, ...);
|
||||
char* tempnam(const char* dir, const char* pfx);
|
||||
FILE* tmpfile(void);
|
||||
char* tmpnam(char* s);
|
||||
int ungetc(int c, FILE* stream);
|
||||
int vdprintf(int fildes, const char* __restrict format, va_list ap);
|
||||
int vfprintf(FILE* __restrict stream, const char* __restrict format, va_list ap);
|
||||
int vfscanf(FILE* __restrict stream, const char* __restrict format, va_list arg);
|
||||
int vprintf(const char* __restrict format, va_list ap);
|
||||
int vscanf(const char* __restrict format, va_list arg);
|
||||
int vsnprintf(char* __restrict s, size_t n, const char* __restrict format, va_list ap);
|
||||
int vsprintf(char* __restrict s, const char* __restrict format, va_list ap);
|
||||
int vsscanf(const char* __restrict s, const char* __restrict format, va_list arg);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
112
userspace/libraries/LibC/include/stdlib.h
Normal file
112
userspace/libraries/LibC/include/stdlib.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#ifndef _STDLIB_H
|
||||
#define _STDLIB_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#define __need_NULL
|
||||
#define __need_size_t
|
||||
#define __need_wchar_t
|
||||
#include <stddef.h>
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
|
||||
#define RAND_MAX INT32_MAX
|
||||
|
||||
#define MB_CUR_MAX ((size_t)4)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int quot; /* quotient */
|
||||
int rem; /* remainder */
|
||||
} div_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long quot; /* quotient */
|
||||
long rem; /* remainder */
|
||||
} ldiv_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
long long quot; /* quotient */
|
||||
long long rem; /* remainder */
|
||||
} lldiv_t;
|
||||
|
||||
void _Exit(int status) __attribute__((__noreturn__));
|
||||
long a64l(const char* s);
|
||||
void abort(void) __attribute__((__noreturn__));
|
||||
int abs(int i);
|
||||
int atexit(void (*func)(void));
|
||||
double atof(const char* str);
|
||||
int atoi(const char* str);
|
||||
long atol(const char* str);
|
||||
long long atoll(const char* str);
|
||||
void* bsearch(const void* key, const void* base, size_t nel, size_t width, int (*compar)(const void*, const void*));
|
||||
void* calloc(size_t nelem, size_t elsize);
|
||||
div_t div(int numer, int denom);
|
||||
double drand48(void);
|
||||
double erand48(unsigned short xsubi[3]);
|
||||
void exit(int status);
|
||||
void free(void* ptr);
|
||||
char* getenv(const char* name);
|
||||
int getsubopt(char** optionp, char* const* keylistp, char** valuep);
|
||||
int grantpt(int fildes);
|
||||
char* initstate(unsigned seed, char* state, size_t size);
|
||||
long jrand48(unsigned short xsubi[3]);
|
||||
char* l64a(long value);
|
||||
long labs(long i);
|
||||
void lcong48(unsigned short param[7]);
|
||||
ldiv_t ldiv(long numer, long denom);
|
||||
long long llabs(long long i);
|
||||
lldiv_t lldiv(long long numer, long long denom);
|
||||
long lrand48(void);
|
||||
void* malloc(size_t size);
|
||||
int mblen(const char* s, size_t n);
|
||||
size_t mbstowcs(wchar_t* __restrict pwcs, const char* __restrict s, size_t n);
|
||||
int mbtowc(wchar_t* __restrict pwc, const char* __restrict s, size_t n);
|
||||
char* mkdtemp(char* _template);
|
||||
int mkstemp(char* _template);
|
||||
long mrand48(void);
|
||||
long nrand48(unsigned short xsubi[3]);
|
||||
int posix_memalign(void** memptr, size_t alignment, size_t size);
|
||||
int posix_openpt(int oflag);
|
||||
char* ptsname(int fildes);
|
||||
int putenv(char* string);
|
||||
void qsort(void* base, size_t nel, size_t width, int (*compar)(const void*, const void*));
|
||||
int rand(void);
|
||||
int rand_r(unsigned* seed);
|
||||
long random(void);
|
||||
void* realloc(void* ptr, size_t size);
|
||||
char* realpath(const char* __restrict file_name, char* __restrict resolved_name);
|
||||
unsigned short* seed48(unsigned short seed16v[3]);
|
||||
int setenv(const char* envname, const char* envval, int overwrite);
|
||||
void setkey(const char* key);
|
||||
char* setstate(char* state);
|
||||
void srand(unsigned seed);
|
||||
void srand48(long seedval);
|
||||
void srandom(unsigned seed);
|
||||
double strtod(const char* __restrict nptr, char** __restrict endptr);
|
||||
float strtof(const char* __restrict nptr, char** __restrict endptr);
|
||||
long strtol(const char* __restrict nptr, char** __restrict endptr, int base);
|
||||
long double strtold(const char* __restrict nptr, char** __restrict endptr);
|
||||
long long strtoll(const char* __restrict nptr, char** __restrict endptr, int base);
|
||||
unsigned long strtoul(const char* __restrict nptr, char** __restrict endptr, int base);
|
||||
unsigned long long strtoull(const char* __restrict nptr, char** __restrict endptr, int base);
|
||||
int system(const char* command);
|
||||
int unlockpt(int fildes);
|
||||
int unsetenv(const char* name);
|
||||
size_t wcstombs(char* __restrict s, const wchar_t* __restrict pwcs, size_t n);
|
||||
int wctomb(char* s, wchar_t wchar);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
54
userspace/libraries/LibC/include/string.h
Normal file
54
userspace/libraries/LibC/include/string.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef _STRING_H
|
||||
#define _STRING_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/string.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <stddef.h>
|
||||
#include <bits/types/locale_t.h>
|
||||
|
||||
void* memccpy(void* __restrict s1, const void* __restrict s2, int c, size_t n);
|
||||
void* memchr(const void* s, int c, size_t n);
|
||||
int memcmp(const void* s1, const void* s2, size_t n);
|
||||
void* memcpy(void* __restrict s1, const void* __restrict s2, size_t n);
|
||||
void* memmove(void* s1, const void* s2, size_t n);
|
||||
void* memset(void* s, int c, size_t n);
|
||||
char* stpcpy(char* __restrict s1, const char* __restrict s2);
|
||||
char* stpncpy(char* __restrict s1, const char* __restrict s2, size_t n);
|
||||
char* strcat(char* __restrict s1, const char* __restrict s2);
|
||||
char* strchr(const char* s, int c);
|
||||
char* strchrnul(const char* s, int c);
|
||||
int strcmp(const char* s1, const char* s2);
|
||||
int strcoll(const char* s1, const char* s2);
|
||||
int strcoll_l(const char* s1, const char* s2, locale_t locale);
|
||||
char* strcpy(char* __restrict s1, const char* __restrict s2);
|
||||
size_t strcspn(const char* s1, const char* s2);
|
||||
char* strdup(const char* s);
|
||||
char* strerror(int errnum);
|
||||
char* strerror_l(int errnum, locale_t locale);
|
||||
int strerror_r(int errnum, char* strerrbuf, size_t buflen);
|
||||
size_t strlen(const char* s);
|
||||
char* strncat(char* __restrict s1, const char* __restrict s2, size_t n);
|
||||
int strncmp(const char* s1, const char* s2, size_t n);
|
||||
char* strncpy(char* __restrict s1, const char* __restrict s2, size_t n);
|
||||
char* strndup(const char* s, size_t n);
|
||||
size_t strnlen(const char* s, size_t maxlen);
|
||||
char* strpbrk(const char* s1, const char* s2);
|
||||
char* strrchr(const char* s, int c);
|
||||
char* strsignal(int signum);
|
||||
size_t strspn(const char* s1, const char* s2);
|
||||
char* strstr(const char* s1, const char* s2);
|
||||
char* strtok(char* __restrict s, const char* __restrict sep);
|
||||
char* strtok_r(char* __restrict s, const char* __restrict sep, char** __restrict state);
|
||||
size_t strxfrm(char* __restrict s1, const char* __restrict s2, size_t n);
|
||||
size_t strxfrm_l(char* __restrict s1, const char* __restrict s2, size_t n, locale_t locale);
|
||||
|
||||
const char* strerrorname_np(int error);
|
||||
const char* strerrordesc_np(int error);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
23
userspace/libraries/LibC/include/strings.h
Normal file
23
userspace/libraries/LibC/include/strings.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _STRINGS_H
|
||||
#define _STRINGS_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/strings.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <bits/types/locale_t.h>
|
||||
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
int ffs(int i);
|
||||
int strcasecmp(const char* s1, const char* s2);
|
||||
int strcasecmp_l(const char* s1, const char* s2, locale_t locale);
|
||||
int strncasecmp(const char* s1, const char* s2, size_t n);
|
||||
int strncasecmp_l(const char* s1, const char* s2, size_t n, locale_t locale);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
153
userspace/libraries/LibC/include/stropts.h
Normal file
153
userspace/libraries/LibC/include/stropts.h
Normal file
@@ -0,0 +1,153 @@
|
||||
#ifndef _STROPTS_H
|
||||
#define _STROPTS_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stropts.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_uid_t
|
||||
#define __need_gid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef __UINT32_TYPE__ t_uscalar_t;
|
||||
typedef __INT32_TYPE__ t_scalar_t;
|
||||
|
||||
struct bandinfo
|
||||
{
|
||||
int bi_flag; /* Flushing type. */
|
||||
unsigned char bi_pri; /* Priority band. */
|
||||
};
|
||||
|
||||
struct strbuf
|
||||
{
|
||||
char* buf; /* Pointer to buffer. */
|
||||
int len; /* Length of data. */
|
||||
int maxlen; /* Maximum buffer length. */
|
||||
};
|
||||
|
||||
struct strpeek
|
||||
{
|
||||
struct strbuf ctlbuf; /* The control portion of the message. */
|
||||
struct strbuf databuf; /* The data portion of the message. */
|
||||
t_uscalar_t flags; /* RS_HIPRI or 0. */
|
||||
};
|
||||
|
||||
struct strfdinsert
|
||||
{
|
||||
struct strbuf ctlbuf; /* The control portion of the message. */
|
||||
struct strbuf databuf; /* The data portion of the message. */
|
||||
int fildes; /* File descriptor of the other STREAM. */
|
||||
t_uscalar_t flags; /* RS_HIPRI or 0. */
|
||||
int offset; /* Relative location of the stored value. */
|
||||
};
|
||||
|
||||
struct strioctl
|
||||
{
|
||||
int ic_cmd; /* ioctl() command. */
|
||||
char* ic_dp; /* Pointer to buffer. */
|
||||
int ic_len; /* Length of data. */
|
||||
int ic_timout; /* Timeout for response. */
|
||||
};
|
||||
|
||||
struct strrecvfd
|
||||
{
|
||||
int fd; /* Received file descriptor. */
|
||||
gid_t gid; /* GID of sender. */
|
||||
uid_t uid; /* UID of sender. */
|
||||
};
|
||||
|
||||
#define FMNAMESZ 128
|
||||
|
||||
struct str_mlist
|
||||
{
|
||||
char l_name[FMNAMESZ+1]; /* A STREAMS module name. */
|
||||
};
|
||||
|
||||
struct str_list
|
||||
{
|
||||
struct str_mlist* sl_modlist; /* STREAMS module names. */
|
||||
int sl_nmods; /* Number of STREAMS module names. */
|
||||
};
|
||||
|
||||
#define I_ATMARK 1
|
||||
#define I_CANPUT 2
|
||||
#define I_CKBAND 3
|
||||
#define I_FDINSERT 4
|
||||
#define I_FIND 5
|
||||
#define I_FLUSH 6
|
||||
#define I_FLUSHBAND 7
|
||||
#define I_GETBAND 8
|
||||
#define I_GETCLTIME 9
|
||||
#define I_GETSIG 10
|
||||
#define I_GRDOPT 11
|
||||
#define I_GWROPT 12
|
||||
#define I_LINK 13
|
||||
#define I_LIST 14
|
||||
#define I_LOOK 15
|
||||
#define I_NREAD 16
|
||||
#define I_PEEK 17
|
||||
#define I_PLINK 18
|
||||
#define I_POP 19
|
||||
#define I_PUNLINK 20
|
||||
#define I_PUSH 21
|
||||
#define I_RECVFD 22
|
||||
#define I_SENDFD 23
|
||||
#define I_SETCLTIME 24
|
||||
#define I_SETSIG 25
|
||||
#define I_SRDOPT 26
|
||||
#define I_STR 27
|
||||
#define I_SWROPT 28
|
||||
#define I_UNLINK 29
|
||||
|
||||
#define FLUSHR 1
|
||||
#define FLUSHRW 2
|
||||
#define FLUSHW 3
|
||||
|
||||
#define S_BANDURG 1
|
||||
#define S_ERROR 2
|
||||
#define S_HANGUP 3
|
||||
#define S_HIPRI 4
|
||||
#define S_INPUT 5
|
||||
#define S_MSG 6
|
||||
#define S_OUTPUT 7
|
||||
#define S_RDBAND 8
|
||||
#define S_RDNORM 9
|
||||
#define S_WRBAND 10
|
||||
#define S_WRNORM 11
|
||||
|
||||
#define RS_HIPRI 1
|
||||
|
||||
#define RMSGD 1
|
||||
#define RMSGN 2
|
||||
#define RNORM 3
|
||||
#define RPROTDAT 4
|
||||
#define RPROTDIS 5
|
||||
#define RPROTNORM 6
|
||||
|
||||
#define SNDZERO 1
|
||||
|
||||
#define ANYMARK 1
|
||||
#define LASTMARK 2
|
||||
|
||||
#define MUXID_ALL 1
|
||||
|
||||
#define MORECTL 1
|
||||
#define MOREDATA 2
|
||||
#define MSG_ANY 3
|
||||
#define MSG_BAND 4
|
||||
#define MSG_HIPRI 5
|
||||
|
||||
int fattach(int, const char*);
|
||||
int fdetach(const char*);
|
||||
int getmsg(int, struct strbuf* __restrict, struct strbuf* __restrict, int* __restrict);
|
||||
int getpmsg(int, struct strbuf* __restrict, struct strbuf* __restrict, int* __restrict, int* __restrict);
|
||||
int ioctl(int, int, ...);
|
||||
int isastream(int);
|
||||
int putmsg(int, const struct strbuf*, const struct strbuf*, int);
|
||||
int putpmsg(int, const struct strbuf*, const struct strbuf*, int, int);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
48
userspace/libraries/LibC/include/sys/banan-os.h
Normal file
48
userspace/libraries/LibC/include/sys/banan-os.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _SYS_BANAN_OS_H
|
||||
#define _SYS_BANAN_OS_H 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t 1
|
||||
#include <stddef.h>
|
||||
|
||||
#define TTY_CMD_SET 0x01
|
||||
#define TTY_CMD_UNSET 0x02
|
||||
|
||||
#define TTY_FLAG_ENABLE_OUTPUT 1
|
||||
#define TTY_FLAG_ENABLE_INPUT 2
|
||||
|
||||
#define POWEROFF_SHUTDOWN 0
|
||||
#define POWEROFF_REBOOT 1
|
||||
|
||||
struct proc_meminfo_t
|
||||
{
|
||||
size_t page_size;
|
||||
size_t virt_pages;
|
||||
size_t phys_pages;
|
||||
};
|
||||
|
||||
/*
|
||||
fildes: refers to valid tty device
|
||||
command: one of TTY_CMD_* definitions
|
||||
flags: bitwise or of TTY_FLAG_* definitions
|
||||
|
||||
return value: 0 on success, -1 on failure and errno set to the error
|
||||
*/
|
||||
int tty_ctrl(int fildes, int command, int flags);
|
||||
int poweroff(int command);
|
||||
|
||||
int load_keymap(const char* path);
|
||||
|
||||
// Create shared memory object and return its key or -1 on error
|
||||
long smo_create(size_t size, int prot);
|
||||
// Delete shared memory object such that it will be no longer accessible with smo_map(). Existing mappings are still valid
|
||||
int smo_delete(long key);
|
||||
// Map shared memory object defined by its key and return address or null on error. Mappings can be unmapped using munmap()
|
||||
void* smo_map(long key);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
14
userspace/libraries/LibC/include/sys/cdefs.h
Normal file
14
userspace/libraries/LibC/include/sys/cdefs.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef _SYS_CDEFS_H
|
||||
#define _SYS_CDEFS_H 1
|
||||
|
||||
#define __banan_libc 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define __BEGIN_DECLS extern "C" {
|
||||
#define __END_DECLS }
|
||||
#else
|
||||
#define __BEGIN_DECLS
|
||||
#define __END_DECLS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
20
userspace/libraries/LibC/include/sys/framebuffer.h
Normal file
20
userspace/libraries/LibC/include/sys/framebuffer.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _FRAMEBUFFER_H
|
||||
#define _FRAMEBUFFER_H 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define BANAN_FB_BPP 32
|
||||
|
||||
struct framebuffer_info_t
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
37
userspace/libraries/LibC/include/sys/ipc.h
Normal file
37
userspace/libraries/LibC/include/sys/ipc.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _SYS_IPC_H
|
||||
#define _SYS_IPC_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_ipc.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_uid_t
|
||||
#define __need_gid_t
|
||||
#define __need_mode_t
|
||||
#define __need_key_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct ipc_perm
|
||||
{
|
||||
uid_t uid; /* Owner's user ID. */
|
||||
gid_t gid; /* Owner's group ID. */
|
||||
uid_t cuid; /* Creator's user ID. */
|
||||
gid_t cgid; /* Creator's group ID. */
|
||||
mode_t mode; /* Read/write permission. */
|
||||
};
|
||||
|
||||
#define IPC_CREAT 0x01
|
||||
#define IPC_EXCL 0x02
|
||||
#define IPC_NOWAIT 0x04
|
||||
#define IPC_PRIVATE 0x08
|
||||
#define IPC_RMID 0x10
|
||||
#define IPC_SET 0x20
|
||||
#define IPC_STAT 0x40
|
||||
|
||||
key_t ftok(const char* path, int id);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
76
userspace/libraries/LibC/include/sys/mman.h
Normal file
76
userspace/libraries/LibC/include/sys/mman.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef _SYS_MMAN_H
|
||||
#define _SYS_MMAN_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_mman.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define PROT_EXEC 0x01
|
||||
#define PROT_NONE 0x02
|
||||
#define PROT_READ 0x04
|
||||
#define PROT_WRITE 0x08
|
||||
|
||||
#define MAP_FIXED 0x01
|
||||
#define MAP_PRIVATE 0x02
|
||||
#define MAP_SHARED 0x04
|
||||
#define MAP_ANONYMOUS 0x08
|
||||
|
||||
#define MS_ASYNC 0x01
|
||||
#define MS_INVALIDATE 0x02
|
||||
#define MS_SYNC 0x04
|
||||
|
||||
#define MCL_CURRENT 0x01
|
||||
#define MCL_FUTURE 0x01
|
||||
|
||||
#define MAP_FAILED ((void*)0)
|
||||
|
||||
#define POSIX_MADV_DONTNEED 1
|
||||
#define POSIX_MADV_NORMAL 2
|
||||
#define POSIX_MADV_RANDOM 3
|
||||
#define POSIX_MADV_SEQUENTIAL 4
|
||||
#define POSIX_MADV_WILLNEED 5
|
||||
|
||||
#define POSIX_TYPED_MEM_ALLOCATE 0x01
|
||||
#define POSIX_TYPED_MEM_ALLOCATE_CONTIG 0x02
|
||||
#define POSIX_TYPED_MEM_MAP_ALLOCATABLE 0x04
|
||||
|
||||
#define __need_mode_t
|
||||
#define __need_off_t
|
||||
#define __need_size_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct posix_typed_mem_info
|
||||
{
|
||||
size_t posix_tmi_length; /* Maximum length which may be allocated from a typed memory object. */
|
||||
};
|
||||
|
||||
struct sys_mmap_t
|
||||
{
|
||||
void* addr;
|
||||
size_t len;
|
||||
int prot;
|
||||
int flags;
|
||||
int fildes;
|
||||
off_t off;
|
||||
};
|
||||
|
||||
int mlock(const void* addr, size_t len);
|
||||
int mlockall(int flags);
|
||||
void* mmap(void* addr, size_t len, int prot, int flags, int fildes, off_t off);
|
||||
int mprotect(void* addr, size_t len, int prot);
|
||||
int msync(void* addr, size_t len, int flags);
|
||||
int munlock(const void* addr, size_t len);
|
||||
int munlockall(void);
|
||||
int munmap(void* addr, size_t len);
|
||||
int posix_madvise(void* addr, size_t len, int advice);
|
||||
int posix_mem_offset(const void* __restrict addr, size_t len, off_t* __restrict off, size_t* __restrict contig_len, int* __restrict fildes);
|
||||
int posix_typed_mem_get_info(int fildes, struct posix_typed_mem_info* info);
|
||||
int posix_typed_mem_open(const char* name, int oflag, int tflag);
|
||||
int shm_open(const char* name, int oflag, mode_t mode);
|
||||
int shm_unlink(const char* name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
42
userspace/libraries/LibC/include/sys/msg.h
Normal file
42
userspace/libraries/LibC/include/sys/msg.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _SYS_MSG_H
|
||||
#define _SYS_MSG_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_msg.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
typedef unsigned int msgqnum_t;
|
||||
typedef unsigned int msglen_t;
|
||||
|
||||
#define MSG_NOERROR 0
|
||||
|
||||
struct msqid_ds
|
||||
{
|
||||
struct ipc_perm msg_perm; /* Operation permission structure. */
|
||||
msgqnum_t msg_qnum; /* Number of messages currently on queue. */
|
||||
msglen_t msg_qbytes; /* Maximum number of bytes allowed on queue. */
|
||||
pid_t msg_lspid; /* Process ID of last msgsnd(). */
|
||||
pid_t msg_lrpid; /* Process ID of last msgrcv(). */
|
||||
time_t msg_stime; /* Time of last msgsnd(). */
|
||||
time_t msg_rtime; /* Time of last msgrcv(). */
|
||||
time_t msg_ctime; /* Time of last change. */
|
||||
};
|
||||
|
||||
int msgctl(int msqid, int cmd, struct msqid_ds* buf);
|
||||
int msgget(key_t key, int msgflg);
|
||||
ssize_t msgrcv(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg);
|
||||
int msgsnd(int msqid, const void* msgp, size_t msgsz, int msgflg);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
56
userspace/libraries/LibC/include/sys/resource.h
Normal file
56
userspace/libraries/LibC/include/sys/resource.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef _SYS_RESOURCE_H
|
||||
#define _SYS_RESOURCE_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_resource.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_id_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#define PRIO_PROCESS 0
|
||||
#define PRIO_PGRP 1
|
||||
#define PRIO_USER 2
|
||||
|
||||
typedef unsigned int rlim_t;
|
||||
|
||||
#define RLIM_INFINITY ((rlim_t)-1)
|
||||
#define RLIM_SAVED_MAX RLIM_INFINITY
|
||||
#define RLIM_SAVED_CUR RLIM_INFINITY
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
#define RUSAGE_CHILDREN 1
|
||||
|
||||
struct rlimit
|
||||
{
|
||||
rlim_t rlim_cur; /* The current (soft) limit. */
|
||||
rlim_t rlim_max; /* The hard limit. */
|
||||
};
|
||||
|
||||
struct rusage
|
||||
{
|
||||
struct timeval ru_utime; /* User time used. */
|
||||
struct timeval ru_stime; /* System time used. */
|
||||
};
|
||||
|
||||
#define RLIMIT_CORE 0
|
||||
#define RLIMIT_CPU 1
|
||||
#define RLIMIT_DATA 2
|
||||
#define RLIMIT_FSIZE 3
|
||||
#define RLIMIT_NOFILE 4
|
||||
#define RLIMIT_STACK 5
|
||||
#define RLIMIT_AS 6
|
||||
|
||||
int getpriority(int which, id_t who);
|
||||
int getrlimit(int resource, struct rlimit* rlp);
|
||||
int getrusage(int who, struct rusage* r_usage);
|
||||
int setpriority(int which, id_t who, int value);
|
||||
int setrlimit(int resource, const struct rlimit* rlp);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
66
userspace/libraries/LibC/include/sys/select.h
Normal file
66
userspace/libraries/LibC/include/sys/select.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef _SYS_SELECT_H
|
||||
#define _SYS_SELECT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_select.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <bits/types/timeval.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
#define FD_SETSIZE 1024
|
||||
|
||||
typedef unsigned long __fd_mask;
|
||||
#define __FD_MASK_SIZE (8 * sizeof(__fd_mask))
|
||||
|
||||
typedef struct {
|
||||
__fd_mask __bits[FD_SETSIZE / __FD_MASK_SIZE];
|
||||
} fd_set;
|
||||
|
||||
#define FD_CLR(fd, setp) \
|
||||
do { \
|
||||
__fd_mask off = (fd) / __FD_MASK_SIZE; \
|
||||
__fd_mask bit = (fd) % __FD_MASK_SIZE; \
|
||||
(setp)->__bits[off] &= ~((__fd_mask)1 << bit); \
|
||||
} while (0)
|
||||
|
||||
#define FD_ISSET(fd, setp) \
|
||||
({ \
|
||||
__fd_mask off = (fd) / __FD_MASK_SIZE; \
|
||||
__fd_mask bit = (fd) % __FD_MASK_SIZE; \
|
||||
(setp)->__bits[off] & ((__fd_mask)1 << bit); \
|
||||
})
|
||||
|
||||
#define FD_SET(fd, setp) \
|
||||
do { \
|
||||
__fd_mask off = (fd) / __FD_MASK_SIZE; \
|
||||
__fd_mask bit = (fd) % __FD_MASK_SIZE; \
|
||||
(setp)->__bits[off] |= ((__fd_mask)1 << bit); \
|
||||
} while (0)
|
||||
|
||||
#define FD_ZERO(setp) \
|
||||
do { \
|
||||
for (int i = 0; i < FD_SETSIZE / __FD_MASK_SIZE; i++) \
|
||||
(setp)->__bits[i] = (__fd_mask)0; \
|
||||
} while (0)
|
||||
|
||||
struct sys_pselect_t
|
||||
{
|
||||
int nfds;
|
||||
fd_set* readfds;
|
||||
fd_set* writefds;
|
||||
fd_set* errorfds;
|
||||
const struct timespec* timeout;
|
||||
const sigset_t* sigmask;
|
||||
};
|
||||
|
||||
int pselect(int nfds, fd_set* __restrict readfds, fd_set* __restrict writefds, fd_set* __restrict errorfds, const struct timespec* __restrict timeout, const sigset_t* __restrict sigmask);
|
||||
int select(int nfds, fd_set* __restrict readfds, fd_set* __restrict writefds, fd_set* __restrict errorfds, struct timeval* __restrict timeout);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
54
userspace/libraries/LibC/include/sys/sem.h
Normal file
54
userspace/libraries/LibC/include/sys/sem.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef _SYS_SEM_H
|
||||
#define _SYS_SEM_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_sem.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#define __need_size_t
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
#define SEM_UNDO 1
|
||||
|
||||
#define GETNCNT 0
|
||||
#define GETPID 1
|
||||
#define GETVAL 2
|
||||
#define GETALL 3
|
||||
#define GETZCNT 4
|
||||
#define SETVAL 5
|
||||
#define SETALL 6
|
||||
|
||||
struct semid_ds
|
||||
{
|
||||
struct ipc_perm sem_perm; /* Operation permission structure. */
|
||||
unsigned short sem_nsems; /* Number of semaphores in set. */
|
||||
time_t sem_otime; /* Last semop() time. */
|
||||
time_t sem_ctime; /* Last time changed by semctl(). */
|
||||
};
|
||||
|
||||
// FIXME: A semaphore shall be represented by an anonymous structure, which shall include the following members:
|
||||
// unsigned short semval; /* Semaphore value. */
|
||||
// pid_t sempid; /* Process ID of last operation. */
|
||||
// unsigned short semncnt; /* Number of processes waiting for semval to become greater than current value. */
|
||||
// unsigned short semzcnt; /* Number of processes waiting for semval to become 0. */
|
||||
|
||||
struct sembuf
|
||||
{
|
||||
unsigned short sem_num; /* Semaphore number. */
|
||||
short sem_op; /* Semaphore operation. */
|
||||
short sem_flg; /* Operation flags. */
|
||||
};
|
||||
|
||||
int semctl(int, int, int, ...);
|
||||
int semget(key_t, int, int);
|
||||
int semop(int, struct sembuf *, size_t);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
42
userspace/libraries/LibC/include/sys/shm.h
Normal file
42
userspace/libraries/LibC/include/sys/shm.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _SYS_SHM_H
|
||||
#define _SYS_SHM_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_shm.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#define __need_size_t
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/ipc.h>
|
||||
|
||||
#define SHM_RDONLY 0x01
|
||||
#define SHM_RDONLY 0x02
|
||||
#define SHM_RDONLY 0x04
|
||||
|
||||
typedef unsigned int shmatt_t;
|
||||
|
||||
struct shmid_ds
|
||||
{
|
||||
struct ipc_perm shm_perm; /* Operation permission structure. */
|
||||
size_t shm_segsz; /* Size of segment in bytes. */
|
||||
pid_t shm_lpid; /* Process ID of last shared memory operation. */
|
||||
pid_t shm_cpid; /* Process ID of creator. */
|
||||
shmatt_t shm_nattch; /* Number of current attaches. */
|
||||
time_t shm_atime; /* Time of last shmat(). */
|
||||
time_t shm_dtime; /* Time of last shmdt(). */
|
||||
time_t shm_ctime; /* Time of last change by shmctl().*/
|
||||
};
|
||||
|
||||
void* shmat(int shmid, const void* shmaddr, int shmflg);
|
||||
int shmctl(int shmid, int cmd, struct shmid_ds* buf);
|
||||
int shmdt(const void* shmaddr);
|
||||
int shmget(key_t key, size_t size, int shmflg);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
160
userspace/libraries/LibC/include/sys/socket.h
Normal file
160
userspace/libraries/LibC/include/sys/socket.h
Normal file
@@ -0,0 +1,160 @@
|
||||
#ifndef _SYS_SOCKET_H
|
||||
#define _SYS_SOCKET_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <bits/types/sa_family_t.h>
|
||||
typedef long socklen_t;
|
||||
|
||||
#if !defined(FILENAME_MAX)
|
||||
#define FILENAME_MAX 256
|
||||
#elif FILENAME_MAX != 256
|
||||
#error "invalid FILENAME_MAX"
|
||||
#endif
|
||||
|
||||
struct sockaddr
|
||||
{
|
||||
sa_family_t sa_family; /* Address family. */
|
||||
char sa_data[]; /* Socket address (variable-length data). */
|
||||
};
|
||||
|
||||
struct sockaddr_storage
|
||||
{
|
||||
sa_family_t ss_family;
|
||||
char ss_storage[FILENAME_MAX];
|
||||
};
|
||||
|
||||
struct msghdr
|
||||
{
|
||||
void* msg_name; /* Optional address. */
|
||||
socklen_t msg_namelen; /* Size of address. */
|
||||
struct iovec* msg_iov; /* Scatter/gather array. */
|
||||
int msg_iovlen; /* Members in msg_iov. */
|
||||
void* msg_control; /* Ancillary data; see below. */
|
||||
socklen_t msg_controllen; /* Ancillary data buffer len. */
|
||||
int msg_flags; /* Flags on received message. */
|
||||
};
|
||||
|
||||
struct cmsghdr
|
||||
{
|
||||
socklen_t cmsg_len; /* Data byte count, including the cmsghdr. */
|
||||
int cmsg_level; /* Originating protocol. */
|
||||
int cmsg_type; /* Protocol-specific type. */
|
||||
};
|
||||
|
||||
// FIXME
|
||||
#if 0
|
||||
#define SCM_RIGHTS
|
||||
|
||||
#define CMSG_DATA(cmsg)
|
||||
#define CMSG_NXTHDR(mhdr, cmsg)
|
||||
#define CMSG_FIRSTHDR(mhdr)
|
||||
#endif
|
||||
|
||||
struct linger
|
||||
{
|
||||
int l_onoff; /* Indicates wheter linger option is enabled. */
|
||||
int l_linger; /* Linger time, in seconds. */
|
||||
};
|
||||
|
||||
#define SOCK_DGRAM 0
|
||||
#define SOCK_RAW 1
|
||||
#define SOCK_SEQPACKET 2
|
||||
#define SOCK_STREAM 3
|
||||
|
||||
#define SOL_SOCKET 1
|
||||
|
||||
#define SO_ACCEPTCONN 0
|
||||
#define SO_BROADCAST 1
|
||||
#define SO_DEBUG 2
|
||||
#define SO_DONTROUTE 3
|
||||
#define SO_ERROR 4
|
||||
#define SO_KEEPALIVE 5
|
||||
#define SO_LINGER 6
|
||||
#define SO_OOBINLINE 7
|
||||
#define SO_RCVBUF 8
|
||||
#define SO_RCVLOWAT 9
|
||||
#define SO_RCVTIMEO 10
|
||||
#define SO_REUSEADDR 11
|
||||
#define SO_SNDBUF 12
|
||||
#define SO_SNDLOWAT 13
|
||||
#define SO_SNDTIMEO 14
|
||||
#define SO_TYPE 15
|
||||
|
||||
#define SOMAXCONN 4096
|
||||
|
||||
#define MSG_CTRUNC 0x01
|
||||
#define MSG_DONTROUTE 0x02
|
||||
#define MSG_EOR 0x04
|
||||
#define MSG_OOB 0x08
|
||||
#define MSG_NOSIGNAL 0x10
|
||||
#define MSG_PEEK 0x20
|
||||
#define MSG_TRUNC 0x40
|
||||
#define MSG_WAITALL 0x80
|
||||
|
||||
#define AF_UNSPEC 0
|
||||
#define AF_INET 1
|
||||
#define AF_INET6 2
|
||||
#define AF_UNIX 3
|
||||
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
#define PF_INET AF_INET
|
||||
#define PF_INET6 AF_INET6
|
||||
#define PF_UNIX AF_UNIX
|
||||
|
||||
#define SHUT_RD 0x01
|
||||
#define SHUT_WR 0x02
|
||||
#define SHUT_RDWR (SHUT_RD | SHUT_WR)
|
||||
|
||||
struct sys_sendto_t
|
||||
{
|
||||
int socket;
|
||||
const void* message;
|
||||
size_t length;
|
||||
int flags;
|
||||
const struct sockaddr* dest_addr;
|
||||
socklen_t dest_len;
|
||||
};
|
||||
|
||||
struct sys_recvfrom_t
|
||||
{
|
||||
int socket;
|
||||
void* buffer;
|
||||
size_t length;
|
||||
int flags;
|
||||
struct sockaddr* address;
|
||||
socklen_t* address_len;
|
||||
};
|
||||
|
||||
int accept(int socket, struct sockaddr* __restrict address, socklen_t* __restrict address_len);
|
||||
int bind(int socket, const struct sockaddr* address, socklen_t address_len);
|
||||
int connect(int socket, const struct sockaddr* address, socklen_t address_len);
|
||||
int getpeername(int socket, struct sockaddr* __restrict address, socklen_t* __restrict address_len);
|
||||
int getsockname(int socket, struct sockaddr* __restrict address, socklen_t* __restrict address_len);
|
||||
int getsockopt(int socket, int level, int option_name, void* __restrict option_value, socklen_t* __restrict option_len);
|
||||
int listen(int socket, int backlog);
|
||||
ssize_t recv(int socket, void* buffer, size_t length, int flags);
|
||||
ssize_t recvfrom(int socket, void* __restrict buffer, size_t length, int flags, struct sockaddr* __restrict address, socklen_t* __restrict address_len);
|
||||
ssize_t recvmsg(int socket, struct msghdr* message, int flags);
|
||||
ssize_t send(int socket, const void* buffer, size_t length, int flags);
|
||||
ssize_t sendmsg(int socket, const struct msghdr* message, int flags);
|
||||
ssize_t sendto(int socket, const void* message, size_t length, int flags, const struct sockaddr* dest_addr, socklen_t dest_len);
|
||||
int setsockopt(int socket, int level, int option_name, const void* option_value, socklen_t option_len);
|
||||
int shutdown(int socket, int how);
|
||||
int sockatmark(int s);
|
||||
int socket(int domain, int type, int protocol);
|
||||
int socketpair(int domain, int type, int protocol, int socket_vector[2]);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
109
userspace/libraries/LibC/include/sys/stat.h
Normal file
109
userspace/libraries/LibC/include/sys/stat.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef _SYS_STAT_H
|
||||
#define _SYS_STAT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_blkcnt_t
|
||||
#define __need_blksize_t
|
||||
#define __need_dev_t
|
||||
#define __need_ino_t
|
||||
#define __need_mode_t
|
||||
#define __need_nlink_t
|
||||
#define __need_uid_t
|
||||
#define __need_gid_t
|
||||
#define __need_off_t
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
struct stat
|
||||
{
|
||||
dev_t st_dev; /* Device ID of device containing file. */
|
||||
ino_t st_ino; /* File serial number. */
|
||||
mode_t st_mode; /* Mode of file (see below). */
|
||||
nlink_t st_nlink; /* Number of hard links to the file. */
|
||||
uid_t st_uid; /* User ID of file. */
|
||||
gid_t st_gid; /* Group ID of file. */
|
||||
dev_t st_rdev; /* Device ID (if file is character or block special). */
|
||||
off_t st_size; /* For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link. For a shared memory object, the length in bytes. For a typed memory object, the length in bytes. For other file types, the use of this field is unspecified. */
|
||||
struct timespec st_atim; /* Last data access timestamp. */
|
||||
struct timespec st_mtim; /* Last data modification timestamp. */
|
||||
struct timespec st_ctim; /* Last file status change timestamp. */
|
||||
blksize_t st_blksize; /* A file system-specific preferred I/O block size for this object. In some file system types, this may vary from file to file. */
|
||||
blkcnt_t st_blocks; /* Number of blocks allocated for this object. */
|
||||
};
|
||||
|
||||
#define st_atime st_atim.tv_sec
|
||||
#define st_ctime st_ctim.tv_sec
|
||||
#define st_mtime st_mtim.tv_sec
|
||||
|
||||
#define S_IRWXU 00700
|
||||
#define S_IRUSR 00400
|
||||
#define S_IWUSR 00200
|
||||
#define S_IXUSR 00100
|
||||
#define S_IRWXG 00070
|
||||
#define S_IRGRP 00040
|
||||
#define S_IWGRP 00020
|
||||
#define S_IXGRP 00010
|
||||
#define S_IRWXO 00007
|
||||
#define S_IROTH 00004
|
||||
#define S_IWOTH 00002
|
||||
#define S_IXOTH 00001
|
||||
#define S_ISUID 04000
|
||||
#define S_ISGID 02000
|
||||
#define S_ISVTX 01000
|
||||
|
||||
#define S_IFIFO 0010000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFBLK 0060000
|
||||
#define S_IFREG 0100000
|
||||
#define S_IFLNK 0120000
|
||||
#define S_IFSOCK 0140000
|
||||
#define S_IFMASK 0170000
|
||||
#define S_IFMT S_IFMASK
|
||||
|
||||
#define S_ISBLK(mode) ((mode & S_IFMASK) == S_IFBLK)
|
||||
#define S_ISCHR(mode) ((mode & S_IFMASK) == S_IFCHR)
|
||||
#define S_ISDIR(mode) ((mode & S_IFMASK) == S_IFDIR)
|
||||
#define S_ISFIFO(mode) ((mode & S_IFMASK) == S_IFIFO)
|
||||
#define S_ISREG(mode) ((mode & S_IFMASK) == S_IFREG)
|
||||
#define S_ISLNK(mode) ((mode & S_IFMASK) == S_IFLNK)
|
||||
#define S_ISSOCK(mode) ((mode & S_IFMASK) == S_IFSOCK)
|
||||
|
||||
// FIXME
|
||||
#if 0
|
||||
#define S_TYPEISMQ(buf)
|
||||
#define S_TYPEISSEM(buf)
|
||||
#define S_TYPEISSHM(buf)
|
||||
#define S_TYPEISTMO(buf)
|
||||
#endif
|
||||
|
||||
#define UTIME_NOW 1000000001
|
||||
#define UTIME_OMIT 1000000002
|
||||
|
||||
int chmod(const char* path, mode_t mode);
|
||||
int fchmod(int fildes, mode_t mode);
|
||||
int fchmodat(int fd, const char* path, mode_t mode, int flag);
|
||||
int fstat(int fildes, struct stat* buf);
|
||||
int fstatat(int fd, const char* __restrict path, struct stat* __restrict buf, int flag);
|
||||
int futimens(int fd, const struct timespec times[2]);
|
||||
int lstat(const char* __restrict path, struct stat* __restrict buf);
|
||||
int mkdir(const char* path, mode_t mode);
|
||||
int mkdirat(int fd, const char* path, mode_t mode);
|
||||
int mkfifo(const char* path, mode_t mode);
|
||||
int mkfifoat(int fd, const char* path, mode_t mode);
|
||||
int mknod(const char* path, mode_t mode, dev_t dev);
|
||||
int mknodat(int fd, const char* path, mode_t mode, dev_t dev);
|
||||
int stat(const char* __restrict path, struct stat* __restrict buf);
|
||||
mode_t umask(mode_t cmask);
|
||||
int utimensat(int fd, const char* path, const struct timespec times[2], int flag);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
37
userspace/libraries/LibC/include/sys/statvfs.h
Normal file
37
userspace/libraries/LibC/include/sys/statvfs.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef _SYS_STATVFS_H
|
||||
#define _SYS_STATVFS_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_fsblkcnt_t
|
||||
#define __need_fsfilcnt_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct statvfs
|
||||
{
|
||||
unsigned long f_bsize; /* File system block size. */
|
||||
unsigned long f_frsize; /* Fundamental file system block size. */
|
||||
fsblkcnt_t f_blocks; /* Total number of blocks on file system in units of f_frsize. */
|
||||
fsblkcnt_t f_bfree; /* Total number of free blocks. */
|
||||
fsblkcnt_t f_bavail; /* Number of free blocks available to non-privileged process. */
|
||||
fsfilcnt_t f_files; /* Total number of file serial numbers. */
|
||||
fsfilcnt_t f_ffree; /* Total number of free file serial numbers. */
|
||||
fsfilcnt_t f_favail; /* Number of file serial numbers available to non-privileged process. */
|
||||
unsigned long f_fsid; /* File system ID. */
|
||||
unsigned long f_flag; /* Bit mask of f_flag values. */
|
||||
unsigned long f_namemax; /* Maximum filename length. */
|
||||
};
|
||||
|
||||
#define ST_RDONLY 0x01
|
||||
#define ST_NOSUID 0x02
|
||||
|
||||
int fstatvfs(int fildes, struct statvfs* buf);
|
||||
int statvfs(const char* __restrict path, struct statvfs* __restrict buf);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
95
userspace/libraries/LibC/include/sys/syscall.h
Normal file
95
userspace/libraries/LibC/include/sys/syscall.h
Normal file
@@ -0,0 +1,95 @@
|
||||
#ifndef _SYS_SYSCALL_H
|
||||
#define _SYS_SYSCALL_H 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __SYSCALL_LIST(O) \
|
||||
O(SYS_EXIT, exit) \
|
||||
O(SYS_READ, read) \
|
||||
O(SYS_WRITE, write) \
|
||||
O(SYS_TERMID, termid) \
|
||||
O(SYS_CLOSE, close) \
|
||||
O(SYS_OPEN, open) \
|
||||
O(SYS_OPENAT, openat) \
|
||||
O(SYS_SEEK, seek) \
|
||||
O(SYS_TELL, tell) \
|
||||
O(SYS_GET_TERMIOS, gettermios) \
|
||||
O(SYS_SET_TERMIOS, settermios) \
|
||||
O(SYS_FORK, fork) \
|
||||
O(SYS_EXEC, exec) \
|
||||
O(SYS_SLEEP, sleep) \
|
||||
O(SYS_WAIT, wait) \
|
||||
O(SYS_FSTAT, fstat) \
|
||||
O(SYS_READ_DIR, readdir) \
|
||||
O(SYS_SET_UID, setuid) \
|
||||
O(SYS_SET_GID, setgid) \
|
||||
O(SYS_SET_EUID, seteuid) \
|
||||
O(SYS_SET_EGID, setegid) \
|
||||
O(SYS_SET_REUID, setreuid) \
|
||||
O(SYS_SET_REGID, setregid) \
|
||||
O(SYS_GET_UID, getuid) \
|
||||
O(SYS_GET_GID, getgid) \
|
||||
O(SYS_GET_EUID, geteuid) \
|
||||
O(SYS_GET_EGID, getegid) \
|
||||
O(SYS_GET_PWD, getpwd) \
|
||||
O(SYS_SET_PWD, setpwd) \
|
||||
O(SYS_CLOCK_GETTIME, clock_gettime) \
|
||||
O(SYS_PIPE, pipe) \
|
||||
O(SYS_DUP, dup) \
|
||||
O(SYS_DUP2, dup2) \
|
||||
O(SYS_KILL, kill) \
|
||||
O(SYS_SIGNAL, signal) \
|
||||
O(SYS_TCSETPGRP, tcsetpgrp) \
|
||||
O(SYS_GET_PID, getpid) \
|
||||
O(SYS_GET_PGID, getpgid) \
|
||||
O(SYS_SET_PGID, setpgid) \
|
||||
O(SYS_FCNTL, fcntl) \
|
||||
O(SYS_NANOSLEEP, nanosleep) \
|
||||
O(SYS_FSTATAT, fstatat) \
|
||||
O(SYS_STAT, stat) \
|
||||
O(SYS_SYNC, sync) \
|
||||
O(SYS_MMAP, mmap) \
|
||||
O(SYS_MUNMAP, munmap) \
|
||||
O(SYS_TTY_CTRL, tty_ctrl) \
|
||||
O(SYS_POWEROFF, poweroff) \
|
||||
O(SYS_CHMOD, chmod) \
|
||||
O(SYS_CREATE, create) \
|
||||
O(SYS_CREATE_DIR, create_dir) \
|
||||
O(SYS_UNLINK, unlink) \
|
||||
O(SYS_READLINK, readlink) \
|
||||
O(SYS_READLINKAT, readlinkat) \
|
||||
O(SYS_MSYNC, msync) \
|
||||
O(SYS_PREAD, pread) \
|
||||
O(SYS_CHOWN, chown) \
|
||||
O(SYS_LOAD_KEYMAP, load_keymap) \
|
||||
O(SYS_SOCKET, socket) \
|
||||
O(SYS_BIND, bind) \
|
||||
O(SYS_SENDTO, sendto) \
|
||||
O(SYS_RECVFROM, recvfrom) \
|
||||
O(SYS_IOCTL, ioctl) \
|
||||
O(SYS_ACCEPT, accept) \
|
||||
O(SYS_CONNECT, connect) \
|
||||
O(SYS_LISTEN, listen) \
|
||||
O(SYS_PSELECT, pselect) \
|
||||
O(SYS_TRUNCATE, truncate) \
|
||||
O(SYS_SMO_CREATE, smo_create) \
|
||||
O(SYS_SMO_DELETE, smo_delete) \
|
||||
O(SYS_SMO_MAP, smo_map) \
|
||||
O(SYS_ISATTY, isatty) \
|
||||
O(SYS_GETSOCKNAME, getsockname) \
|
||||
O(SYS_GETSOCKOPT, getsockopt) \
|
||||
O(SYS_SETSOCKOPT, setsockopt) \
|
||||
|
||||
enum Syscall
|
||||
{
|
||||
#define O(enum, name) enum,
|
||||
__SYSCALL_LIST(O)
|
||||
#undef O
|
||||
__SYSCALL_COUNT
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
18
userspace/libraries/LibC/include/sys/sysmacros.h
Normal file
18
userspace/libraries/LibC/include/sys/sysmacros.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _SYS_SYSMACROS_H
|
||||
#define _SYS_SYSMACROS_H 1
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#define makedev(maj, min) ((dev_t)(maj) << 32 | (dev_t)(min))
|
||||
|
||||
#define major(dev) (((dev) >> 32) & 0xFFFFFFFF)
|
||||
#define minor(dev) ( (dev) & 0xFFFFFFFF)
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
32
userspace/libraries/LibC/include/sys/time.h
Normal file
32
userspace/libraries/LibC/include/sys/time.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _SYS_TIME_H
|
||||
#define _SYS_TIME_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_time.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
// NOTE: select is declared from here
|
||||
#include <sys/select.h>
|
||||
|
||||
#include <bits/types/timeval.h>
|
||||
|
||||
struct itimerval
|
||||
{
|
||||
struct timeval it_interval; /* Timer interval. */
|
||||
struct timeval it_value; /* Current value. */
|
||||
};
|
||||
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
int getitimer(int which, struct itimerval* value);
|
||||
int gettimeofday(struct timeval* __restrict tp, void* __restrict tzp);
|
||||
int setitimer(int which, const struct itimerval* __restrict value, struct itimerval* __restrict ovalue);
|
||||
int utimes(const char* path, const struct timeval times[2]);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
25
userspace/libraries/LibC/include/sys/times.h
Normal file
25
userspace/libraries/LibC/include/sys/times.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _SYS_TIMES_H
|
||||
#define _SYS_TIMES_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_times.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_clock_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct tms
|
||||
{
|
||||
clock_t tms_utime; /* User CPU time. */
|
||||
clock_t tms_stime; /* System CPU time. */
|
||||
clock_t tms_cutime; /* User CPU time of terminated child processes. */
|
||||
clock_t tms_cstime; /* System CPU time of terminated child processes. */
|
||||
};
|
||||
|
||||
clock_t times(struct tms* buffer);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
196
userspace/libraries/LibC/include/sys/types.h
Normal file
196
userspace/libraries/LibC/include/sys/types.h
Normal file
@@ -0,0 +1,196 @@
|
||||
#ifndef _SYS_TYPES_H
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#if !defined(__need_blkcnt_t) \
|
||||
&& !defined(__need_blksize_t) \
|
||||
&& !defined(__need_clock_t) \
|
||||
&& !defined(__need_clockid_t) \
|
||||
&& !defined(__need_dev_t) \
|
||||
&& !defined(__need_fsblkcnt_t) \
|
||||
&& !defined(__need_fsfilcnt_t) \
|
||||
&& !defined(__need_gid_t) \
|
||||
&& !defined(__need_id_t) \
|
||||
&& !defined(__need_ino_t) \
|
||||
&& !defined(__need_key_t) \
|
||||
&& !defined(__need_mode_t) \
|
||||
&& !defined(__need_nlink_t) \
|
||||
&& !defined(__need_off_t) \
|
||||
&& !defined(__need_pid_t) \
|
||||
&& !defined(__need_pthread_attr_t) \
|
||||
&& !defined(__need_pthread_barrier_t) \
|
||||
&& !defined(__need_pthread_barrierattr_t) \
|
||||
&& !defined(__need_pthread_cond_t) \
|
||||
&& !defined(__need_pthread_condattr_t) \
|
||||
&& !defined(__need_pthread_key_t) \
|
||||
&& !defined(__need_pthread_mutex_t) \
|
||||
&& !defined(__need_pthread_mutexattr_t) \
|
||||
&& !defined(__need_pthread_once_t) \
|
||||
&& !defined(__need_pthread_rwlock_t) \
|
||||
&& !defined(__need_pthread_rwlockattr_t) \
|
||||
&& !defined(__need_pthread_spinlock_t) \
|
||||
&& !defined(__need_pthread_t) \
|
||||
&& !defined(__need_size_t) \
|
||||
&& !defined(__need_ssize_t) \
|
||||
&& !defined(__need_suseconds_t) \
|
||||
&& !defined(__need_time_t) \
|
||||
&& !defined(__need_timer_t) \
|
||||
&& !defined(__need_uid_t)
|
||||
|
||||
#define __need_all_types
|
||||
#endif
|
||||
|
||||
#ifdef __need_all_types
|
||||
#define _SYS_TYPES_H 1
|
||||
#endif
|
||||
|
||||
#if !defined(__blkcnt_t_defined) && (defined(__need_all_types) || defined(__need_blkcnt_t))
|
||||
#define __blkcnt_defined 1
|
||||
typedef long blkcnt_t;
|
||||
#endif
|
||||
#undef __need_blkcnt_t
|
||||
|
||||
#if !defined(__blksize_t_defined) && (defined(__need_all_types) || defined(__need_blksize_t))
|
||||
#define __blksize_t_defined 1
|
||||
typedef long blksize_t;
|
||||
#endif
|
||||
#undef __need_blksize_t
|
||||
|
||||
#if !defined(__clock_t_defined) && (defined(__need_all_types) || defined(__need_clock_t))
|
||||
#define __clock_t_defined 1
|
||||
typedef long clock_t;
|
||||
#endif
|
||||
#undef __need_clock_t
|
||||
|
||||
#if !defined(__clockid_t_defined) && (defined(__need_all_types) || defined(__need_clockid_t))
|
||||
#define __clockid_t_defined 1
|
||||
typedef int clockid_t;
|
||||
#endif
|
||||
#undef __need_clockid_t
|
||||
|
||||
#if !defined(__dev_t_defined) && (defined(__need_all_types) || defined(__need_dev_t))
|
||||
#define __dev_t_defined 1
|
||||
typedef unsigned long dev_t;
|
||||
#endif
|
||||
#undef __need_dev_t
|
||||
|
||||
#if !defined(__fsblkcnt_t_defined) && (defined(__need_all_types) || defined(__need_fsblkcnt_t))
|
||||
#define __fsblkcnt_t_defined 1
|
||||
typedef unsigned long fsblkcnt_t;
|
||||
#endif
|
||||
#undef __need_fsblkcnt_t
|
||||
|
||||
#if !defined(__fsfilcnt_t_defined) && (defined(__need_all_types) || defined(__need_fsfilcnt_t))
|
||||
#define __fsfilcnt_t_defined 1
|
||||
typedef unsigned long fsfilcnt_t;
|
||||
#endif
|
||||
#undef __need_fsfilcnt_t
|
||||
|
||||
#if !defined(__gid_t_defined) && (defined(__need_all_types) || defined(__need_gid_t))
|
||||
#define __gid_t_defined 1
|
||||
typedef int gid_t;
|
||||
#endif
|
||||
#undef __need_gid_t
|
||||
|
||||
#if !defined(__id_t_defined) && (defined(__need_all_types) || defined(__need_id_t))
|
||||
#define __id_t_defined 1
|
||||
typedef int id_t;
|
||||
#endif
|
||||
#undef __need_id_t
|
||||
|
||||
#if !defined(__ino_t_defined) && (defined(__need_all_types) || defined(__need_ino_t))
|
||||
#define __ino_t_defined 1
|
||||
typedef unsigned long long ino_t;
|
||||
#endif
|
||||
#undef __need_ino_t
|
||||
|
||||
#if !defined(__key_t_defined) && (defined(__need_all_types) || defined(__need_key_t))
|
||||
#define __key_t_defined 1
|
||||
typedef int key_t;
|
||||
#endif
|
||||
#undef __need_key_t
|
||||
|
||||
#if !defined(__mode_t_defined) && (defined(__need_all_types) || defined(__need_mode_t))
|
||||
#define __mode_t_defined 1
|
||||
typedef unsigned int mode_t;
|
||||
#endif
|
||||
#undef __need_mode_t
|
||||
|
||||
#if !defined(__nlink_t_defined) && (defined(__need_all_types) || defined(__need_nlink_t))
|
||||
#define __nlink_t_defined 1
|
||||
typedef unsigned long nlink_t;
|
||||
#endif
|
||||
#undef __need_nlink_t
|
||||
|
||||
#if !defined(__off_t_defined) && (defined(__need_all_types) || defined(__need_off_t))
|
||||
#define __off_t_defined 1
|
||||
typedef long off_t;
|
||||
#endif
|
||||
#undef __need_off_t
|
||||
|
||||
#if !defined(__pid_t_defined) && (defined(__need_all_types) || defined(__need_pid_t))
|
||||
#define __pid_t_defined 1
|
||||
typedef int pid_t;
|
||||
#endif
|
||||
#undef __need_pid_t
|
||||
|
||||
#include <bits/pthread_types.h>
|
||||
|
||||
#if !defined(__size_t_defined) && (defined(__need_all_types) || defined(__need_size_t))
|
||||
#define __size_t_defined 1
|
||||
#define __need_size_t
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
#undef __need_size_t
|
||||
|
||||
#if !defined(__ssize_t_defined) && (defined(__need_all_types) || defined(__need_ssize_t))
|
||||
#define __ssize_t_defined 1
|
||||
#if __SIZEOF_SIZE_T__ == __SIZEOF_INT__
|
||||
typedef int ssize_t;
|
||||
#elif __SIZEOF_SIZE_T__ == __SIZEOF_LONG__
|
||||
typedef long ssize_t;
|
||||
#elif __SIZEOF_SIZE_T__ == __SIZEOF_LONG_LONG__
|
||||
typedef long long ssize_t;
|
||||
#else
|
||||
#error "unsupported sizeof(size_t)"
|
||||
#endif
|
||||
#endif
|
||||
#undef __need_ssize_t
|
||||
|
||||
#if !defined(__suseconds_t_defined) && (defined(__need_all_types) || defined(__need_suseconds_t))
|
||||
#define __suseconds_t_defined 1
|
||||
typedef long suseconds_t;
|
||||
#endif
|
||||
#undef __need_suseconds_t
|
||||
|
||||
#if !defined(__time_t_defined) && (defined(__need_all_types) || defined(__need_time_t))
|
||||
#define __time_t_defined 1
|
||||
typedef unsigned long long time_t;
|
||||
#endif
|
||||
#undef __need_time_t
|
||||
|
||||
#if !defined(__timer_t_defined) && (defined(__need_all_types) || defined(__need_timer_t))
|
||||
#define __timer_t_defined 1
|
||||
typedef void* timer_t;
|
||||
#endif
|
||||
#undef __need_timer_t
|
||||
|
||||
#if !defined(__uid_t_defined) && (defined(__need_all_types) || defined(__need_uid_t))
|
||||
#define __uid_t_defined 1
|
||||
typedef int uid_t;
|
||||
#endif
|
||||
#undef __need_uid_t
|
||||
|
||||
#ifdef __need_all_types
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#undef __need_all_types
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
25
userspace/libraries/LibC/include/sys/uio.h
Normal file
25
userspace/libraries/LibC/include/sys/uio.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _SYS_UIO_H
|
||||
#define _SYS_UIO_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_uio.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct iovec
|
||||
{
|
||||
void* iov_base; /* Base address of a memory region for input or output. */
|
||||
size_t iov_len; /* The size of the memory pointed to by iov_base. */
|
||||
};
|
||||
|
||||
ssize_t readv(int fildes, const struct iovec* iov, int iovcnt);
|
||||
ssize_t writev(int fildes, const struct iovec* iov, int iovcnt);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
20
userspace/libraries/LibC/include/sys/un.h
Normal file
20
userspace/libraries/LibC/include/sys/un.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _SYS_UN_H
|
||||
#define _SYS_UN_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_un.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <bits/types/sa_family_t.h>
|
||||
|
||||
struct sockaddr_un
|
||||
{
|
||||
sa_family_t sun_family; /* Address family. */
|
||||
char sun_path[FILENAME_MAX]; /* Socket pathname. */
|
||||
};
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
23
userspace/libraries/LibC/include/sys/utsname.h
Normal file
23
userspace/libraries/LibC/include/sys/utsname.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _SYS_UTSNAME_H
|
||||
#define _SYS_UTSNAME_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_utsname.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct utsname
|
||||
{
|
||||
char sysname[65]; /* Name of this implementation of the operating system. */
|
||||
char nodename[65]; /* Name of this node within the communications network to which this node is attached, if any. */
|
||||
char release[65]; /* Current release level of this implementation. */
|
||||
char version[65]; /* Current version level of this release. */
|
||||
char machine[65]; /* Name of the hardware type on which the system is running. */
|
||||
};
|
||||
|
||||
int uname(struct utsname* name);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
45
userspace/libraries/LibC/include/sys/wait.h
Normal file
45
userspace/libraries/LibC/include/sys/wait.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef _SYS_WAIT_H
|
||||
#define _SYS_WAIT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_wait.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_id_t
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#define WCONTINUED 0x01
|
||||
#define WNOHANG 0x02
|
||||
#define WUNTRACED 0x04
|
||||
#define WEXITED 0x08
|
||||
#define WNOWAIT 0x10
|
||||
#define WSTOPPED 0x20
|
||||
|
||||
#define WEXITSTATUS(status) (((status) >> 8) & 0xFF)
|
||||
#define WSTOPSIG(status) WEXITSTATUS(status)
|
||||
#define WTERMSIG(status) ((status) & 0x7F)
|
||||
#define WIFEXITED(status) (WTERMSIG(status) == 0)
|
||||
#define WIFSIGNALED(status) (((status) & 0x7F) > 0 && ((status) & 0x7F) < 0x7F)
|
||||
#define WIFSTOPPED(status) (((status) & 0xFF) == 0x7F)
|
||||
|
||||
#define __WGENEXITCODE(ret, sig) (((ret) << 8) | (sig))
|
||||
|
||||
typedef enum
|
||||
{
|
||||
P_ALL,
|
||||
P_PGID,
|
||||
P_PID,
|
||||
} idtype_t;
|
||||
|
||||
pid_t wait(int* stat_loc);
|
||||
int waitid(idtype_t idtype, id_t id, siginfo_t* infop, int options);
|
||||
pid_t waitpid(pid_t pid, int* stat_loc, int options);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
52
userspace/libraries/LibC/include/syslog.h
Normal file
52
userspace/libraries/LibC/include/syslog.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef _SYSLOG_H
|
||||
#define _SYSLOG_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/syslog.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define LOG_PID 0x01
|
||||
#define LOG_CONS 0x02
|
||||
#define LOG_NDELAY 0x04
|
||||
#define LOG_ODELAY 0x08
|
||||
#define LOG_NOWAIT 0x10
|
||||
|
||||
#define LOG_EMERG 0
|
||||
#define LOG_ALERT 1
|
||||
#define LOG_CRIT 2
|
||||
#define LOG_ERR 3
|
||||
#define LOG_WARNING 4
|
||||
#define LOG_NOTICE 5
|
||||
#define LOG_INFO 6
|
||||
#define LOG_DEBUG 7
|
||||
|
||||
#define LOG_KERN ( 0 << 3)
|
||||
#define LOG_USER ( 1 << 3)
|
||||
#define LOG_MAIL ( 2 << 3)
|
||||
#define LOG_NEWS ( 3 << 3)
|
||||
#define LOG_UUCP ( 4 << 3)
|
||||
#define LOG_DAEMON ( 5 << 3)
|
||||
#define LOG_AUTH ( 6 << 3)
|
||||
#define LOG_CRON ( 7 << 3)
|
||||
#define LOG_LPR ( 8 << 3)
|
||||
#define LOG_LOCAL0 ( 9 << 3)
|
||||
#define LOG_LOCAL1 (10 << 3)
|
||||
#define LOG_LOCAL2 (11 << 3)
|
||||
#define LOG_LOCAL3 (12 << 3)
|
||||
#define LOG_LOCAL4 (13 << 3)
|
||||
#define LOG_LOCAL5 (14 << 3)
|
||||
#define LOG_LOCAL6 (15 << 3)
|
||||
#define LOG_LOCAL7 (16 << 3)
|
||||
|
||||
#define LOG_MASK(pri) (1 << (pri))
|
||||
|
||||
void closelog(void);
|
||||
void openlog(const char* ident, int logopt, int facility);
|
||||
int setlogmask(int maskpri);
|
||||
void syslog(int priority, const char* message, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
40
userspace/libraries/LibC/include/tar.h
Normal file
40
userspace/libraries/LibC/include/tar.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef _TAR_H
|
||||
#define _TAR_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/tar.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define TMAGIC "ustar"
|
||||
#define TMAGLEN 6
|
||||
#define TVERSION "00"
|
||||
#define TVERSLEN 2
|
||||
|
||||
#define REGTYPE '0'
|
||||
#define AREGTYPE '\0'
|
||||
#define LNKTYPE '1'
|
||||
#define SYMTYPE '2'
|
||||
#define CHRTYPE '3'
|
||||
#define BLKTYPE '4'
|
||||
#define DIRTYPE '5'
|
||||
#define FIFOTYPE '6'
|
||||
#define CONTTYPE '7'
|
||||
|
||||
#define TSUID 04000
|
||||
#define TSGID 02000
|
||||
#define TSVTX 01000
|
||||
#define TUREAD 00400
|
||||
#define TUWRITE 00200
|
||||
#define TUEXEC 00100
|
||||
#define TGREAD 00040
|
||||
#define TGWRITE 00020
|
||||
#define TGEXEC 00010
|
||||
#define TOREAD 00004
|
||||
#define TOWRITE 00002
|
||||
#define TOEXEC 00001
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
149
userspace/libraries/LibC/include/termios.h
Normal file
149
userspace/libraries/LibC/include/termios.h
Normal file
@@ -0,0 +1,149 @@
|
||||
#ifndef _TERMIOS_H
|
||||
#define _TERMIOS_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/termios.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef unsigned int cc_t;
|
||||
typedef unsigned int speed_t;
|
||||
typedef unsigned int tcflag_t;
|
||||
|
||||
#define VEOF 0
|
||||
#define VEOL 1
|
||||
#define VERASE 2
|
||||
#define VINTR 3
|
||||
#define VKILL 4
|
||||
#define VMIN 5
|
||||
#define VQUIT 6
|
||||
#define VSTART 7
|
||||
#define VSTOP 8
|
||||
#define VSUSP 9
|
||||
#define VTIME 10
|
||||
|
||||
#define NCCS 11
|
||||
|
||||
struct termios
|
||||
{
|
||||
tcflag_t c_iflag; /* Input modes. */
|
||||
tcflag_t c_oflag; /* Output modes. */
|
||||
tcflag_t c_cflag; /* Control modes. */
|
||||
tcflag_t c_lflag; /* Local modes. */
|
||||
cc_t c_cc[NCCS]; /* Control characters. */
|
||||
};
|
||||
|
||||
#define BRKINT 0x001
|
||||
#define ICRNL 0x002
|
||||
#define IGNBRK 0x004
|
||||
#define IGNCR 0x008
|
||||
#define IGNPAR 0x010
|
||||
#define INLCR 0x020
|
||||
#define INPCK 0x040
|
||||
#define ISTRIP 0x080
|
||||
#define IXANY 0x100
|
||||
#define IXOFF 0x200
|
||||
#define IXON 0x400
|
||||
#define PARMRK 0x800
|
||||
|
||||
#define OPOST 0x0001
|
||||
#define ONLCR 0x0002
|
||||
#define OCRNL 0x0004
|
||||
#define ONOCR 0x0008
|
||||
#define ONLRET 0x0010
|
||||
#define OFDEL 0x0020
|
||||
#define OFILL 0x0040
|
||||
#define NLDLY 0x0080
|
||||
#define NL0 0x0000
|
||||
#define NL1 0x0080
|
||||
#define CRDLY 0x0300
|
||||
#define CR0 0x0000
|
||||
#define CR1 0x0100
|
||||
#define CR2 0x0200
|
||||
#define CR3 0x0300
|
||||
#define TABDLY 0x0C00
|
||||
#define TAB0 0x0000
|
||||
#define TAB1 0x0400
|
||||
#define TAB2 0x0800
|
||||
#define TAB3 0x0C00
|
||||
#define BSDLY 0x1000
|
||||
#define BS0 0x0000
|
||||
#define BS1 0x1000
|
||||
#define VTDLY 0x2000
|
||||
#define VT0 0x0000
|
||||
#define VT1 0x2000
|
||||
#define FFDLY 0x4000
|
||||
#define FF0 0x0000
|
||||
#define FF1 0x4000
|
||||
|
||||
#define B0 0
|
||||
#define B50 1
|
||||
#define B75 2
|
||||
#define B110 3
|
||||
#define B134 4
|
||||
#define B150 5
|
||||
#define B200 6
|
||||
#define B300 7
|
||||
#define B600 8
|
||||
#define B1200 9
|
||||
#define B1800 10
|
||||
#define B2400 11
|
||||
#define B4800 12
|
||||
#define B9600 13
|
||||
#define B19200 14
|
||||
#define B38400 15
|
||||
|
||||
#define CSIZE 0x03
|
||||
#define CS5 0x00
|
||||
#define CS6 0x01
|
||||
#define CS7 0x02
|
||||
#define CS8 0x03
|
||||
#define CSTOPB 0x04
|
||||
#define CREAD 0x08
|
||||
#define PARENB 0x10
|
||||
#define PARODD 0x20
|
||||
#define HUPCL 0x40
|
||||
#define CLOCAL 0x80
|
||||
|
||||
#define ECHO 0x001
|
||||
#define ECHOE 0x002
|
||||
#define ECHOK 0x004
|
||||
#define ECHONL 0x008
|
||||
#define ICANON 0x010
|
||||
#define IEXTEN 0x020
|
||||
#define ISIG 0x040
|
||||
#define NOFLSH 0x080
|
||||
#define TOSTOP 0x100
|
||||
|
||||
#define TCSANOW 0
|
||||
#define TCSADRAIN 1
|
||||
#define TCSAFLUSH 2
|
||||
|
||||
#define TCIFLUSH 0x01
|
||||
#define TCOFLUSH 0x02
|
||||
#define TCIOFLUSH (TCIFLUSH | TCOFLUSH)
|
||||
|
||||
#define TCIOFF 0
|
||||
#define TCION 1
|
||||
#define TCOOFF 2
|
||||
#define TCOON 3
|
||||
|
||||
speed_t cfgetispeed(const struct termios* termios_p);
|
||||
speed_t cfgetospeed(const struct termios* termios_p);
|
||||
int cfsetispeed(struct termios* termios_p, speed_t speed);
|
||||
int cfsetospeed(struct termios* termios_p, speed_t speed);
|
||||
int tcdrain(int fildes);
|
||||
int tcflow(int fildes, int action);
|
||||
int tcflush(int fildes, int queue_selector);
|
||||
int tcgetattr(int fildes, struct termios* termios_p);
|
||||
pid_t tcgetsid(int fildes);
|
||||
int tcsendbreak(int fildes, int duration);
|
||||
int tcsetattr(int fildes, int optional_actions, const struct termios* termios_p);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
17
userspace/libraries/LibC/include/tgmath.h
Normal file
17
userspace/libraries/LibC/include/tgmath.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef _TGMATH_H
|
||||
#define _TGMATH_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/tgmath.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#include <math.h>
|
||||
#include <complex.h>
|
||||
|
||||
// FIXME
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
97
userspace/libraries/LibC/include/time.h
Normal file
97
userspace/libraries/LibC/include/time.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef _TIME_H
|
||||
#define _TIME_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_clock_t
|
||||
#define __need_size_t
|
||||
#define __need_time_t
|
||||
#define __need_clockid_t
|
||||
#define __need_timer_t
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
#define __need_NULL
|
||||
#include <stddef.h>
|
||||
|
||||
#include <bits/types/locale_t.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
struct tm
|
||||
{
|
||||
int tm_sec; /* Seconds [0,60]. */
|
||||
int tm_min; /* Minutes [0,59]. */
|
||||
int tm_hour; /* Hour [0,23]. */
|
||||
int tm_mday; /* Day of month [1,31]. */
|
||||
int tm_mon; /* Month of year [0,11]. */
|
||||
int tm_year; /* Years since 1900. */
|
||||
int tm_wday; /* Day of week [0,6] (Sunday =0). */
|
||||
int tm_yday; /* Day of year [0,365]. */
|
||||
int tm_isdst; /* Daylight Savings flag. */
|
||||
};
|
||||
|
||||
struct timespec
|
||||
{
|
||||
time_t tv_sec; /* Seconds. */
|
||||
long tv_nsec; /* Nanoseconds. */
|
||||
};
|
||||
|
||||
struct itimerspec
|
||||
{
|
||||
struct timespec it_interval; /* Timer period. */
|
||||
struct timespec it_value; /* Timer expiration. */
|
||||
};
|
||||
|
||||
#define CLOCKS_PER_SEC ((clock_t)1000000)
|
||||
|
||||
#define CLOCK_MONOTONIC 0
|
||||
#define CLOCK_PROCESS_CPUTIME_ID 1
|
||||
#define CLOCK_REALTIME 2
|
||||
#define CLOCK_THREAD_CPUTIME_ID 3
|
||||
|
||||
#define TIMER_ABSTIME 1
|
||||
|
||||
// FIXME
|
||||
// #define getdate_err(int)
|
||||
|
||||
char* asctime(const struct tm* timeptr);
|
||||
char* asctime_r(const struct tm* __restrict tm, char* __restrict buf);
|
||||
clock_t clock(void);
|
||||
int clock_getcpuclockid(pid_t pid, clockid_t* clock_id);
|
||||
int clock_getres(clockid_t clock_id, struct timespec* res);
|
||||
int clock_gettime(clockid_t clock_id, struct timespec* tp);
|
||||
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec* rqtp, struct timespec* rmtp);
|
||||
int clock_settime(clockid_t clock_id, const struct timespec* tp);
|
||||
char* ctime(const time_t* clock);
|
||||
char* ctime_r(const time_t* clock, char* buf);
|
||||
double difftime(time_t time1, time_t time0);
|
||||
struct tm* getdate(const char* string);
|
||||
struct tm* gmtime(const time_t* timer);
|
||||
struct tm* gmtime_r(const time_t* __restrict timer, struct tm* __restrict result);
|
||||
struct tm* localtime(const time_t* timer);
|
||||
struct tm* localtime_r(const time_t* __restrict timer, struct tm* __restrict result);
|
||||
time_t mktime(struct tm* timeptr);
|
||||
int nanosleep(const struct timespec* rqtp, struct timespec* rmtp);
|
||||
size_t strftime(char* __restrict s, size_t maxsize, const char* __restrict format, const struct tm* __restrict timeptr);
|
||||
size_t strftime_l(char* __restrict s, size_t maxsize, const char* __restrict format, const struct tm* __restrict timeptr, locale_t locale);
|
||||
char* strptime(const char* __restrict buf, const char* __restrict format, struct tm* __restrict tm);
|
||||
time_t time(time_t* tloc);
|
||||
int timer_create(clockid_t clockid, struct sigevent* __restrict evp, timer_t* __restrict timerid);
|
||||
int timer_delete(timer_t timerid);
|
||||
int timer_getoverrun(timer_t timerid);
|
||||
int timer_gettime(timer_t timerid, struct itimerspec* value);
|
||||
int timer_settime(timer_t timerid, int, const struct itimerspec* __restrict value, struct itimerspec* __restrict ovalue);
|
||||
void tzset(void);
|
||||
|
||||
extern int daylight;
|
||||
extern long timezone;
|
||||
extern char* tzname[];
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
17
userspace/libraries/LibC/include/ulimit.h
Normal file
17
userspace/libraries/LibC/include/ulimit.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef _ULIMIT_H
|
||||
#define _ULIMIT_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ulimit.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define UL_GETFSIZE 0
|
||||
#define UL_SETFSIZE 1
|
||||
|
||||
long ulimit(int, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
218
userspace/libraries/LibC/include/unistd.h
Normal file
218
userspace/libraries/LibC/include/unistd.h
Normal file
@@ -0,0 +1,218 @@
|
||||
#ifndef _UNISTD_H
|
||||
#define _UNISTD_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define _POSIX_VERSION 200809L
|
||||
#define _POSIX2_VERSION -1
|
||||
#define _XOPEN_VERSION 700
|
||||
|
||||
#define _POSIX_ADVISORY_INFO -1
|
||||
#define _POSIX_ASYNCHRONOUS_IO -1
|
||||
#define _POSIX_BARRIERS -1
|
||||
#define _POSIX_CHOWN_RESTRICTED -1
|
||||
#define _POSIX_CLOCK_SELECTION -1
|
||||
#define _POSIX_CPUTIME -1
|
||||
#define _POSIX_FSYNC -1
|
||||
#define _POSIX_IPV6 -1
|
||||
#define _POSIX_JOB_CONTROL -1
|
||||
#define _POSIX_MAPPED_FILES -1
|
||||
#define _POSIX_MEMLOCK -1
|
||||
#define _POSIX_MEMLOCK_RANGE -1
|
||||
#define _POSIX_MEMORY_PROTECTION -1
|
||||
#define _POSIX_MESSAGE_PASSING -1
|
||||
#define _POSIX_MONOTONIC_CLOCK -1
|
||||
#define _POSIX_NO_TRUNC -1
|
||||
#define _POSIX_PRIORITIZED_IO -1
|
||||
#define _POSIX_PRIORITY_SCHEDULING -1
|
||||
#define _POSIX_RAW_SOCKETS -1
|
||||
#define _POSIX_READER_WRITER_LOCKS -1
|
||||
#define _POSIX_REALTIME_SIGNALS -1
|
||||
#define _POSIX_REGEXP -1
|
||||
#define _POSIX_SAVED_IDS -1
|
||||
#define _POSIX_SEMAPHORES -1
|
||||
#define _POSIX_SHARED_MEMORY_OBJECTS -1
|
||||
#define _POSIX_SHELL -1
|
||||
#define _POSIX_SPAWN -1
|
||||
#define _POSIX_SPIN_LOCKS -1
|
||||
#define _POSIX_SPORADIC_SERVER -1
|
||||
#define _POSIX_SYNCHRONIZED_IO xx
|
||||
#define _POSIX_THREAD_ATTR_STACKADDR -1
|
||||
#define _POSIX_THREAD_ATTR_STACKSIZE -1
|
||||
#define _POSIX_THREAD_CPUTIME -1
|
||||
#define _POSIX_THREAD_PRIO_INHERIT -1
|
||||
#define _POSIX_THREAD_PRIO_PROTECT -1
|
||||
#define _POSIX_THREAD_PRIORITY_SCHEDULING -1
|
||||
#define _POSIX_THREAD_PROCESS_SHARED -1
|
||||
#define _POSIX_THREAD_ROBUST_PRIO_INHERIT -1
|
||||
#define _POSIX_THREAD_ROBUST_PRIO_PROTECT -1
|
||||
#define _POSIX_THREAD_SAFE_FUNCTIONS -1
|
||||
#define _POSIX_THREAD_SPORADIC_SERVER -1
|
||||
#define _POSIX_THREADS -1
|
||||
#define _POSIX_TIMEOUTS -1
|
||||
#define _POSIX_TIMERS -1
|
||||
#define _POSIX_TRACE -1
|
||||
#define _POSIX_TRACE_EVENT_FILTER -1
|
||||
#define _POSIX_TRACE_INHERIT -1
|
||||
#define _POSIX_TRACE_LOG -1
|
||||
#define _POSIX_TYPED_MEMORY_OBJECTS -1
|
||||
#define _POSIX_V6_ILP32_OFF32 -1
|
||||
#define _POSIX_V6_ILP32_OFFBIG -1
|
||||
#define _POSIX_V6_LP64_OFF64 -1
|
||||
#define _POSIX_V6_LPBIG_OFFBIG -1
|
||||
#define _POSIX_V7_ILP32_OFF32 -1
|
||||
#define _POSIX_V7_ILP32_OFFBIG -1
|
||||
#define _POSIX_V7_LP64_OFF64 -1
|
||||
#define _POSIX_V7_LPBIG_OFFBIG -1
|
||||
#define _POSIX2_C_BIND -1
|
||||
#define _POSIX2_C_DEV -1
|
||||
#define _POSIX2_CHAR_TERM -1
|
||||
#define _POSIX2_FORT_DEV -1
|
||||
#define _POSIX2_FORT_RUN -1
|
||||
#define _POSIX2_LOCALEDEF -1
|
||||
#define _POSIX2_PBS -1
|
||||
#define _POSIX2_PBS_ACCOUNTING -1
|
||||
#define _POSIX2_PBS_CHECKPOINT -1
|
||||
#define _POSIX2_PBS_LOCATE -1
|
||||
#define _POSIX2_PBS_MESSAGE -1
|
||||
#define _POSIX2_PBS_TRACK -1
|
||||
#define _POSIX2_SW_DEV -1
|
||||
#define _POSIX2_UPE -1
|
||||
#define _XOPEN_CRYPT -1
|
||||
#define _XOPEN_ENH_I18N -1
|
||||
#define _XOPEN_REALTIME -1
|
||||
#define _XOPEN_REALTIME_THREADS -1
|
||||
#define _XOPEN_SHM -1
|
||||
#define _XOPEN_STREAMS -1
|
||||
#define _XOPEN_UNIX -1
|
||||
#define _XOPEN_UUCP -1
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define __need_size_t
|
||||
#define __need_ssize_t
|
||||
#define __need_uid_t
|
||||
#define __need_gid_t
|
||||
#define __need_off_t
|
||||
#define __need_pid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
// FIXME: _CS prefixed definitions
|
||||
|
||||
// FIXME: _PC prefixed definitions
|
||||
|
||||
#define F_OK 0x01
|
||||
#define R_OK 0x02
|
||||
#define W_OK 0x04
|
||||
#define X_OK 0x08
|
||||
|
||||
#define F_LOCK 0
|
||||
#define F_TEST 1
|
||||
#define F_TLOCK 2
|
||||
#define F_ULOCK 3
|
||||
|
||||
#define STDIN_FILENO 0
|
||||
#define STDOUT_FILENO 1
|
||||
#define STDERR_FILENO 2
|
||||
#define STDDBG_FILENO 3
|
||||
|
||||
#define _POSIX_VDISABLE 0
|
||||
|
||||
int access(const char* path, int amode);
|
||||
unsigned alarm(unsigned seconds);
|
||||
int chdir(const char* path);
|
||||
int chown(const char* path, uid_t owner, gid_t group);
|
||||
int close(int fildes);
|
||||
size_t confstr(int name, char* buf, size_t len);
|
||||
char* crypt(const char* key, const char* salt);
|
||||
int dup(int fildes);
|
||||
int dup2(int fildes, int fildes2);
|
||||
void _exit(int status) __attribute__((__noreturn__));
|
||||
void encrypt(char block[64], int edflag);
|
||||
int execl(const char* path, const char* arg0, ...);
|
||||
int execle(const char* path, const char* arg0, ...);
|
||||
int execlp(const char* file, const char* arg0, ...);
|
||||
int execv(const char* path, char* const argv[]);
|
||||
int execve(const char* path, char* const argv[], char* const envp[]);
|
||||
int execvp(const char* file, char* const argv[]);
|
||||
int faccessat(int fd, const char* path, int amode, int flag);
|
||||
int fchdir(int fildes);
|
||||
int fchown(int fildes, uid_t owner, gid_t group);
|
||||
int fchownat(int fd, const char* path, uid_t owner, gid_t group, int flag);
|
||||
int fdatasync(int fildes);
|
||||
int fexecve(int fd, char* const argv[], char* const envp[]);
|
||||
pid_t fork(void);
|
||||
long fpathconf(int fildes, int name);
|
||||
int fsync(int fildes);
|
||||
int ftruncate(int fildes, off_t length);
|
||||
char* getcwd(char* buf , size_t size);
|
||||
gid_t getegid(void);
|
||||
uid_t geteuid(void);
|
||||
gid_t getgid(void);
|
||||
int getgroups(int gidsetsize, gid_t grouplist[]);
|
||||
long gethostid(void);
|
||||
int gethostname(char* name, size_t namelen);
|
||||
char* getlogin(void);
|
||||
int getlogin_r(char* name, size_t namesize);
|
||||
int getopt(int argc, char* const argv[], const char* optstring);
|
||||
pid_t getpgid(pid_t pid);
|
||||
pid_t getpgrp(void);
|
||||
pid_t getpid(void);
|
||||
pid_t getppid(void);
|
||||
pid_t getsid(pid_t pid);
|
||||
uid_t getuid(void);
|
||||
int isatty(int fildes);
|
||||
int lchown(const char* path, uid_t owner, gid_t group);
|
||||
int link(const char* path1, const char* path2);
|
||||
int linkat(int fd1, const char* path1, int fd2, const char* path2, int flag);
|
||||
int lockf(int fildes, int function, off_t size);
|
||||
off_t lseek(int fildes, off_t offset, int whence);
|
||||
int nice(int incr);
|
||||
long pathconf(const char* path, int name);
|
||||
int pause(void);
|
||||
int pipe(int fildes[2]);
|
||||
ssize_t pread(int fildes, void* buf, size_t nbyte, off_t offset);
|
||||
ssize_t pwrite(int fildes, const void* buf, size_t nbyte, off_t offset);
|
||||
ssize_t read(int fildes, void* buf, size_t nbyte);
|
||||
ssize_t readlink(const char* __restrict path, char* __restrict buf, size_t bufsize);
|
||||
ssize_t readlinkat(int fd, const char* __restrict path, char* __restrict buf, size_t bufsize);
|
||||
int rmdir(const char* path);
|
||||
int setegid(gid_t gid);
|
||||
int seteuid(uid_t uid);
|
||||
int setgid(gid_t gid);
|
||||
int setpgid(pid_t pid, pid_t pgid);
|
||||
pid_t setpgrp(void);
|
||||
int setregid(gid_t rgid, gid_t egid);
|
||||
int setreuid(uid_t ruid, uid_t euid);
|
||||
pid_t setsid(void);
|
||||
int setuid(uid_t uid);
|
||||
unsigned sleep(unsigned seconds);
|
||||
void swab(const void* __restrict src, void* __restrict dest, ssize_t nbytes);
|
||||
int symlink(const char* path1, const char* path2);
|
||||
int symlinkat(const char* path1, int fd, const char* path2);
|
||||
void sync(void);
|
||||
void syncsync(int should_block);
|
||||
long sysconf(int name);
|
||||
pid_t tcgetpgrp(int fildes);
|
||||
int tcsetpgrp(int fildes, pid_t pgid_id);
|
||||
int truncate(const char* path, off_t length);
|
||||
char* ttyname(int fildes);
|
||||
int ttyname_r(int fildes, char* name, size_t namesize);
|
||||
int unlink(const char* path);
|
||||
int unlinkat(int fd, const char* path, int flag);
|
||||
ssize_t write(int fildes, const void* buf, size_t nbyte);
|
||||
|
||||
extern char* optarg;
|
||||
extern int opterr, optind, optopt;
|
||||
|
||||
long syscall(long syscall, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
23
userspace/libraries/LibC/include/utime.h
Normal file
23
userspace/libraries/LibC/include/utime.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _UTIME_H
|
||||
#define _UTIME_H 1
|
||||
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/utime.h.html
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define __need_time_t
|
||||
#include <sys/types.h>
|
||||
|
||||
struct utimbuf
|
||||
{
|
||||
time_t actime; /* Access time. */
|
||||
time_t modtime; /* Modification time. */
|
||||
};
|
||||
|
||||
int utime(const char* path, const struct utimbuf* times);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user