summaryrefslogtreecommitdiff
path: root/lib/libc/include
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/include')
-rw-r--r--lib/libc/include/arch/aarch64/syscall.h85
-rw-r--r--lib/libc/include/arch/amd64/syscall.h105
-rw-r--r--lib/libc/include/crypto/sha256.h (renamed from lib/libc/include/bits/types.h)54
-rw-r--r--lib/libc/include/fcntl.h3
-rw-r--r--lib/libc/include/fenv.h61
-rw-r--r--lib/libc/include/math.h274
-rw-r--r--lib/libc/include/ousi/errno.h103
-rw-r--r--lib/libc/include/stdarg.h92
-rw-r--r--lib/libc/include/stdatomic.h119
-rw-r--r--lib/libc/include/stddef.h149
-rw-r--r--lib/libc/include/stdint.h28
-rw-r--r--lib/libc/include/stdio.h106
-rw-r--r--lib/libc/include/stdlib.h97
-rw-r--r--lib/libc/include/stdlib/errno.h39
-rw-r--r--lib/libc/include/string.h48
-rw-r--r--lib/libc/include/time.h37
-rw-r--r--lib/libc/include/unistd.h21
17 files changed, 1359 insertions, 62 deletions
diff --git a/lib/libc/include/arch/aarch64/syscall.h b/lib/libc/include/arch/aarch64/syscall.h
new file mode 100644
index 0000000..84a51e0
--- /dev/null
+++ b/lib/libc/include/arch/aarch64/syscall.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MACHINE_SYSCALL_H_
+#define _MACHINE_SYSCALL_H_
+
+#if !defined(__ASSEMBLER__)
+__always_inline static inline long
+syscall0(uint64_t code)
+{
+ return 0;
+}
+
+__always_inline static inline long
+syscall1(uint64_t code, uint64_t arg0)
+{
+ return 0;
+}
+
+__always_inline static long inline
+syscall2(uint64_t code, uint64_t arg0, uint64_t arg1)
+{
+ return 0;
+}
+
+__always_inline static inline long
+syscall3(uint64_t code, uint64_t arg0, uint64_t arg1, uint64_t arg2)
+{
+ return 0;
+}
+
+__always_inline static inline long
+syscall4(uint64_t code, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3)
+{
+ return 0;
+}
+
+__always_inline static inline long
+syscall5(uint64_t code, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4)
+{
+ return 0;
+}
+
+__always_inline static inline long
+syscall6(uint64_t code, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5)
+{
+ return 0;
+}
+
+#define _SYSCALL_N(a0, a1, a2, a3, a4, a5, a6, name, ...) \
+ name
+
+#define syscall(...) \
+_SYSCALL_N(__VA_ARGS__, syscall6, syscall5, \
+ syscall4, syscall3, syscall2, syscall1, \
+ syscall0)(__VA_ARGS__)
+
+#endif /* !__ASSEMBLER__ */
+#endif /* !_MACHINE_SYSCALL_H_ */
diff --git a/lib/libc/include/arch/amd64/syscall.h b/lib/libc/include/arch/amd64/syscall.h
new file mode 100644
index 0000000..cc401e9
--- /dev/null
+++ b/lib/libc/include/arch/amd64/syscall.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MACHINE_SYSCALL_H_
+#define _MACHINE_SYSCALL_H_
+
+#if !defined(__ASSEMBLER__)
+__always_inline static inline long
+syscall0(uint64_t code)
+{
+ volatile long ret;
+ __ASMV("int $0x80" : "=a"(ret) : "a"(code));
+ return ret;
+}
+
+__always_inline static inline long
+syscall1(uint64_t code, uint64_t arg0)
+{
+ volatile long ret;
+ __ASMV("int $0x80" : "=a"(ret) : "a"(code), "D"(arg0) : "memory");
+ return ret;
+}
+
+__always_inline static long inline
+syscall2(uint64_t code, uint64_t arg0, uint64_t arg1)
+{
+ volatile long ret;
+ __ASMV("int $0x80" : "=a"(ret) : "a"(code), "D"(arg0), "S"(arg1) : "memory");
+ return ret;
+}
+
+__always_inline static inline long
+syscall3(uint64_t code, uint64_t arg0, uint64_t arg1, uint64_t arg2)
+{
+ volatile long ret;
+ __ASMV("int $0x80" : "=a"(ret) : "a"(code), "D"(arg0), "S"(arg1), "d"(arg2) : "memory");
+ return ret;
+}
+
+__always_inline static inline long
+syscall4(uint64_t code, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3)
+{
+ volatile long ret;
+ register uint64_t _arg3 asm("r10") = arg3;
+ __ASMV("int $0x80" : "=a"(ret) : "a"(code), "D"(arg0), "S"(arg1), "d"(arg2), "r"(_arg3) : "memory");
+ return ret;
+}
+
+__always_inline static inline long
+syscall5(uint64_t code, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4)
+{
+ volatile long ret;
+ register uint64_t _arg3 asm("r10") = arg3;
+ register uint64_t _arg4 asm("r9") = arg4;
+ __ASMV("int $0x80" : "=a"(ret) : "a"(code), "D"(arg0), "S"(arg1), "d"(arg2), "r"(_arg3), "r"(_arg4) : "memory");
+ return ret;
+}
+
+__always_inline static inline long
+syscall6(uint64_t code, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5)
+{
+ volatile long ret;
+ register uint64_t _arg3 asm("r10") = arg3;
+ register uint64_t _arg4 asm("r9") = arg4;
+ register uint64_t _arg5 asm("r8") = arg5;
+ __ASMV("int $0x80" : "=a"(ret) : "a"(code), "D"(arg0), "S"(arg1), "d"(arg2), "r"(_arg3), "r"(_arg4), "r"(_arg5) : "memory");
+ return ret;
+}
+
+#define _SYSCALL_N(a0, a1, a2, a3, a4, a5, a6, name, ...) \
+ name
+
+#define syscall(...) \
+_SYSCALL_N(__VA_ARGS__, syscall6, syscall5, \
+ syscall4, syscall3, syscall2, syscall1, \
+ syscall0)(__VA_ARGS__)
+
+#endif /* !__ASSEMBLER__ */
+#endif /* !_MACHINE_SYSCALL_H_ */
diff --git a/lib/libc/include/bits/types.h b/lib/libc/include/crypto/sha256.h
index 7b0c2f4..6bd1077 100644
--- a/lib/libc/include/bits/types.h
+++ b/lib/libc/include/crypto/sha256.h
@@ -27,38 +27,36 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _BITS_TYPES_H
-#define _BITS_TYPES_H
+#ifndef _CRYPTO_SHA256_H
+#define _CRYPTO_SHA256_H 1
-/* Fixed width integer types */
-typedef unsigned long __size_t;
-typedef long __ssize_t;
-typedef long __ptrdiff_t;
+#include <stddef.h>
+#include <stdint.h>
-typedef unsigned char __uint8_t;
-typedef unsigned short __uint16_t;
-typedef unsigned int __uint32_t;
-typedef unsigned long long __uint64_t;
+#define SHA256_HEX_SIZE (64 + 1)
+#define SHA256_BYTES_SIZE 32
-typedef signed char __int8_t;
-typedef short __int16_t;
-typedef int __int32_t;
-typedef long long __int64_t;
+/*
+ * Compute the SHA-256 checksum of a memory region given a pointer and
+ * the size of that memory region.
+ * The output is a hexadecimal string of 65 characters.
+ * The last character will be the null-character.
+ */
+void sha256_hex(const void *src, size_t n_bytes, char *dst_hex65);
-/* Fixed width integer type limits */
-#define __INT8_MIN (-0x7F - 1)
-#define __INT16_MIN (-0x7FFF - 1)
-#define __INT32_MIN (-0x7FFFFFFF - 1)
-#define __INT64_MIN (-0x7FFFFFFFFFFFFFFFLL - 1)
+void sha256_bytes(const void *src, size_t n_bytes, void *dst_bytes32);
-#define __INT8_MAX 0x7F
-#define __INT16_MAX 0x7FFF
-#define __INT32_MAX 0x7FFFFFFF
-#define __INT64_MAX 0x7FFFFFFFFFFFFFFFLL
+typedef struct sha256 {
+ uint32_t state[8];
+ uint8_t buffer[64];
+ uint64_t n_bits;
+ uint8_t buffer_counter;
+} sha256;
-#define __UINT8_MAX 0xFF
-#define __UINT16_MAX 0xFFFF
-#define __UINT32_MAX 0xFFFFFFFFU
-#define __UINT64_MAX 0xFFFFFFFFFFFFFFFFULL
+/* Functions to compute streaming SHA-256 checksums. */
+void sha256_init(struct sha256 *sha);
+void sha256_append(struct sha256 *sha, const void *data, size_t n_bytes);
+void sha256_finalize_hex(struct sha256 *sha, char *dst_hex65);
+void sha256_finalize_bytes(struct sha256 *sha, void *dst_bytes32);
-#endif /* !_BITS_TYPES_H */
+#endif /* !_CRYPTO_SHA256_H */
diff --git a/lib/libc/include/fcntl.h b/lib/libc/include/fcntl.h
index 8b439d2..5f5ed8a 100644
--- a/lib/libc/include/fcntl.h
+++ b/lib/libc/include/fcntl.h
@@ -30,9 +30,8 @@
#ifndef _FCNTL_H
#define _FCNTL_H
-#include <sys/types.h>
-#include <sys/fcntl.h>
#include <sys/cdefs.h>
+#include <sys/fcntl.h>
__BEGIN_DECLS
diff --git a/lib/libc/include/fenv.h b/lib/libc/include/fenv.h
new file mode 100644
index 0000000..d0e2fec
--- /dev/null
+++ b/lib/libc/include/fenv.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _FENV_H_
+#define _FENV_H_ 1A
+
+#include <sys/types.h>
+
+typedef struct {
+ __uint32_t __control_word;
+ __uint32_t __status_word;
+ __uint32_t __unused[5];
+ __uint32_t __mxcsr;
+} fenv_t;
+
+typedef __uint16_t fexcept_t;
+
+#define FE_TONEAREST 0
+#define FE_DOWNWARD 0x400
+#define FE_UPWARD 0x800
+#define FE_TOWARDZERO 0xC00
+
+int feclearexcept(int __excepts);
+int fegetenv(fenv_t *__envp);
+int fegetexceptflag(fexcept_t *__envp, int __excepts);
+int fegetround(void);
+int feholdexcept(fenv_t *__envp);
+int feraiseexcept(int __excepts);
+int fesetenv(const fenv_t *__envp);
+int fesetexceptflag(const fexcept_t *__envp, int __excepts);
+int fesetround(int __round);
+int fetestexcept(int __excepts);
+int feupdateenv(const fenv_t *__envp);
+
+#endif /* !_FENV_H_ */
diff --git a/lib/libc/include/math.h b/lib/libc/include/math.h
new file mode 100644
index 0000000..13988cb
--- /dev/null
+++ b/lib/libc/include/math.h
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MATH_H_
+#define _MATH_H_ 1
+
+#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 M_PIl 3.141592653589793238462643383279502884L
+
+#define FP_ILOGBNAN (-1 - (int)(((unsigned)-1) >> 1))
+#define FP_ILOGB0 FP_ILOGBNAN
+#define FP_INFINITE 1
+#define FP_NAN 2
+#define FP_NORMAL 4
+#define FP_SUBNORMAL 8
+#define FP_ZERO 16
+
+#define isfinite(x) (fpclassify(x) & (FP_NORMAL | FP_SUBNORMAL | FP_ZERO))
+#define isnan(x) (fpclassify(x) == FP_NAN)
+#define isinf(x) (fpclassify(x) == FP_INFINITE)
+#define isnormal(x) (fpclassify(x) == FP_NORMAL)
+#define signbit(x) (__builtin_signbit(x))
+
+#define INFINITY (__builtin_inff())
+#define NAN (__builtin_nanf(""))
+
+int __fpclassify(double __x);
+int __fpclassifyf(float __x);
+int __fpclassifyl(long double __x);
+
+#define fpclassify(x) \
+ (sizeof(x) == sizeof(double) ? __fpclassify(x) : \
+ (sizeof(x) == sizeof(float) ? __fpclassifyf(x) : \
+ (sizeof(x) == sizeof(long double) ? __fpclassifyl(x) : \
+ 0)))
+
+typedef double double_t;
+typedef float float_t;
+
+double exp10(double __x);
+float exp10f(float __x);
+long double exp10l(long double __x);
+
+double exp(double __x);
+float expf(float __x);
+long double expl(long double __x);
+
+double exp2(double __x);
+float exp2f(float __x);
+long double exp2l(long double __x);
+
+double expm1(double __x);
+float expm1f(float __x);
+long double expm1l(long double __x);
+
+double frexp(double __x, int *__power);
+float frexpf(float __x, int *__power);
+long double frexpl(long double __x, int *__power);
+
+int ilogb(double __x);
+int ilogbf(float __x);
+int ilogbl(long double __x);
+
+double ldexp(double __x, int __power);
+float ldexpf(float __x, int __power);
+long double ldexpl(long double __x, int __power);
+
+double log(double __x);
+float logf(float __x);
+long double logl(long double __x);
+
+double log10(double __x);
+float log10f(float __x);
+long double log10l(long double __x);
+
+double log1p(double __x);
+float log1pf(float __x);
+long double log1pl(long double __x);
+
+double log2(double __x);
+float log2f(float __x);
+long double log2l(long double __x);
+
+double logb(double __x);
+float logbf(float __x);
+long double logbl(long double __x);
+
+double modf(double __x, double *__integral);
+float modff(float __x, float *__integral);
+long double modfl(long double __x, long double *__integral);
+
+double scalbn(double __x, int __power);
+float scalbnf(float __x, int __power);
+long double scalbnl(long double __x, int __power);
+
+double scalbln(double __x, long __power);
+float scalblnf(float __x, long __power);
+long double scalblnl(long double __x, long __power);
+
+double cbrt(double __x);
+float cbrtf(float __x);
+long double cbrtl(long double __x);
+
+double fabs(double __x);
+float fabsf(float __x);
+long double fabsl(long double __x);
+
+double hypot(double __x, double __y);
+float hypotf(float __x, float __y);
+long double hypotl(long double __x, long double __y);
+
+double pow(double __x, double __y);
+float powf(float __x, float __y);
+long double powl(long double __x, long double __y);
+
+double sqrt(double __x);
+float sqrtf(float __x);
+long double sqrtl(long double __x);
+
+double erf(double __x);
+float erff(float __x);
+long double erfl(long double __x);
+
+double erfc(double __x);
+float erfcf(float __x);
+long double erfcl(long double __x);
+
+double lgamma(double __x);
+float lgammaf(float __x);
+long double lgammal(long double __x);
+
+double tgamma(double __x);
+float tgammaf(float __x);
+long double tgammal(long double __x);
+
+double ceil(double __x);
+float ceilf(float __x);
+long double ceill(long double __x);
+
+double floor(double __x);
+float floorf(float __x);
+long double floorl(long double __x);
+
+double nearbyint(double __x);
+float nearbyintf(float __x);
+long double nearbyintl(long double __x);
+
+double rint(double __x);
+float rintf(float __x);
+long double rintl(long double __x);
+
+long lrint(double __x);
+long lrintf(float __x);
+long lrintl(long double __x);
+
+long long llrint(double __x);
+long long llrintf(float __x);
+long long llrintl(long double __x);
+
+double round(double __x);
+float roundf(float __x);
+long double roundl(long double __x);
+
+long lround(double __x);
+long lroundf(float __x);
+long lroundl(long double __x);
+
+long long llround(double __x);
+long long llroundf(float __x);
+long long llroundl(long double __x);
+
+double trunc(double __x);
+float truncf(float __x);
+long double truncl(long double __x);
+
+double fmod(double __x, double __y);
+float fmodf(float __x, float __y);
+long double fmodl(long double __x, long double __y);
+
+double remainder(double __x, double __y);
+float remainderf(float __x, float __y);
+long double remainderl(long double __x, long double __y);
+
+double remquo(double __x, double __y, int *__quotient);
+float remquof(float __x, float __y, int *__quotient);
+long double remquol(long double __x, long double __y, int *__quotient);
+
+double copysign(double __x, double __sign);
+float copysignf(float __x, float __sign);
+long double copysignl(long double __x, long double __sign);
+
+double nan(const char *__tag);
+float nanf(const char *__tag);
+long double nanl(const char *__tag);
+
+double nextafter(double __x, double __dir);
+float nextafterf(float __x, float __dir);
+long double nextafterl(long double __x, long double __dir);
+
+double nexttoward(double __x, long double __dir);
+float nexttowardf(float __x, long double __dir);
+long double nexttowardl(long double __x, long double __dir);
+
+double fdim(double __x, double __y);
+float fdimf(float __x, float __y);
+long double fdiml(long double __x, long double __y);
+
+double fmax(double __x, double __y);
+float fmaxf(float __x, float __y);
+long double fmaxl(long double __x, long double __y);
+
+double fmin(double __x, double __y);
+float fminf(float __x, float __y);
+long double fminl(long double __x, long double __y);
+
+double atan(double __x);
+float atanf(float __x);
+long double atanl(long double __x);
+
+double atan2(double __x, double __y);
+float atan2f(float __x, float __y);
+long double atan2l(long double __x, long double __y);
+
+double cos(double __x);
+float cosf(float __x);
+long double cosl(long double __x);
+
+double sin(double __x);
+float sinf(float __x);
+long double sinl(long double __x);
+
+double tan(double __x);
+float tanf(float __x);
+long double tanl(long double __x);
+
+#endif /* !_MATH_H_ */
diff --git a/lib/libc/include/ousi/errno.h b/lib/libc/include/ousi/errno.h
new file mode 100644
index 0000000..a73f60b
--- /dev/null
+++ b/lib/libc/include/ousi/errno.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _OUSI_ERRNO_H_
+#define _OUSI_ERRNO_H_
+
+#define EPERM 1 /* Not super-user */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Arg list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No children */
+#define EAGAIN 11 /* No more processes */
+#define ENOMEM 12 /* Not enough core */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Mount device busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* Too many open files in system */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define ETIME 62 /* Timer expired */
+#define ENOLINK 67 /* The link has been severed */
+#define EPROTO 71 /* Protocol error */
+#define EMULTIHOP 74 /* Multihop attempted */
+#define EBADMSG 77 /* Trying to read unreadable message */
+#define EBADFD 81 /* f.d. invalid for this operation */
+#define ENOTEMPTY 90 /* Directory not empty */
+#define ENAMETOOLONG 91 /* File or path name too long */
+#define ELOOP 92 /* Too many symbolic links */
+#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
+#define EPFNOSUPPORT 96 /* Protocol family not supported */
+#define ECONNRESET 104 /* Connection reset by peer */
+#define ENOBUFS 105 /* No buffer space available */
+#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */
+#define EPROTOTYPE 107 /* Protocol wrong type for socket */
+#define ENOTSOCK 108 /* Socket operation on non-socket */
+#define ENOPROTOOPT 109 /* Protocol not available */
+#define ESHUTDOWN 110 /* Can't send after socket shutdown */
+#define ECONNREFUSED 111 /* Connection refused */
+#define EADDRINUSE 112 /* Address already in use */
+#define ECONNABORTED 113 /* Connection aborted */
+#define ENETUNREACH 114 /* Network is unreachable */
+#define ENETDOWN 115 /* Network interface is not configured */
+#define ETIMEDOUT 116 /* Connection timed out */
+#define EHOSTDOWN 117 /* Host is down */
+#define EHOSTUNREACH 118 /* Host is unreachable */
+#define EINPROGRESS 119 /* Connection already in progress */
+#define EALREADY 120 /* Socket already connected */
+#define EDESTADDRREQ 121 /* Destination address required */
+#define EMSGSIZE 122 /* Message too long */
+#define EPROTONOSUPPORT 123 /* Unknown protocol */
+#define ESOCKTNOSUPPORT 124 /* Socket type not supported */
+#define EADDRNOTAVAIL 125 /* Address not available */
+#define EISCONN 127 /* Socket is already connected */
+#define ENOTCONN 128 /* Socket is not connected */
+#define ENOTSUP 134 /* Not supported */
+#define EOVERFLOW 139 /* Value too large for defined data type */
+
+#endif /* !_OUSI_ERRNO_H_ */
diff --git a/lib/libc/include/stdarg.h b/lib/libc/include/stdarg.h
new file mode 100644
index 0000000..dc75475
--- /dev/null
+++ b/lib/libc/include/stdarg.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _STDARG_H
+#define _STDARG_H 1
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+#define __STDC_VERSION_STDARG_H__ 202311L
+#endif
+
+/* Determine which definitions are needed */
+#if !defined(__need___va_list) && !defined(__need_va_list) && \
+ !defined(__need_va_arg) && \
+ !defined(__need___va_copy) && !defined(__need_va_copy)
+#define __need___va_list
+#define __need_va_list
+#define __need_va_arg
+#define __need___va_copy
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined(__cplusplus) && __cplusplus >= 201103L)
+#define __need_va_copy
+#endif
+#endif
+
+/* __gnuc_va_list type */
+#ifdef __need___va_list
+#ifndef __GNUC_VA_LIST
+#define __GNUC_VA_LIST
+typedef __builtin_va_list __gnuc_va_list;
+#endif /* !__GNUC_VA_LIST */
+#undef __need___va_list
+#endif /* __need___va_list */
+
+/* va_list type */
+#ifdef __need_va_list
+#ifndef _VA_LIST
+#define _VA_LIST
+typedef __builtin_va_list va_list;
+#endif /* !_VA_LIST */
+#undef __need_va_list
+#endif /* __need_va_list */
+
+/* va_start(), va_end(), and va_arg() macros */
+#ifdef __need_va_arg
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+#define va_start(ap, ...) __builtin_va_start(ap, 0)
+#else
+#define va_start(ap, arg) __builtin_va_start(ap, arg)
+#endif
+#define va_end(ap) __builtin_va_end(ap)
+#define va_arg(ap, type) __builtin_va_arg(ap, type)
+#undef __need_va_arg
+#endif /* __need_va_arg */
+
+/* __va_copy() macro */
+#ifdef __need___va_copy
+#define __va_copy(dest, src) __builtin_va_copy(dest, src)
+#undef __need___va_copy
+#endif /* __need___va_copy */
+
+/* va_copy() macro */
+#ifdef __need_va_copy
+#define va_copy(dest, src) __builtin_va_copy(dest, src)
+#undef __need_va_copy
+#endif /* __need_va_copy */
+
+#endif /* !_STDARG_H */
diff --git a/lib/libc/include/stdatomic.h b/lib/libc/include/stdatomic.h
new file mode 100644
index 0000000..3f80270
--- /dev/null
+++ b/lib/libc/include/stdatomic.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _STDATOMIC_H
+#define _STDATOMIC_H 1
+
+#include <stddef.h>
+#include <stdint.h>
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+#define __STDC_VERSION_STDATOMIC_H__ 202311L
+#endif
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+
+#define kill_dependency(y) (y)
+
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 202311L) || defined(__cplusplus)
+/* Deprecated in C17, removed in C23 */
+#define ATOMIC_VAR_INIT(value) (value)
+#endif
+
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || defined(__cplusplus)
+#define ATOMIC_FLAG_INIT { false }
+typedef _Atomic(bool) atomic_bool;
+#else
+#define ATOMIC_FLAG_INIT { 0 }
+typedef _Atomic(_Bool) atomic_bool;
+#endif
+
+typedef _Atomic(signed char) atomic_schar;
+
+typedef _Atomic(char) atomic_char;
+typedef _Atomic(short) atomic_short;
+typedef _Atomic(int) atomic_int;
+typedef _Atomic(long) atomic_long;
+typedef _Atomic(long long) atomic_llong;
+
+typedef _Atomic(unsigned char) atomic_uchar;
+typedef _Atomic(unsigned short) atomic_ushort;
+typedef _Atomic(unsigned int) atomic_uint;
+typedef _Atomic(unsigned long) atomic_ulong;
+typedef _Atomic(unsigned long long) atomic_ullong;
+
+typedef _Atomic(uintptr_t) atomic_uintptr_t;
+typedef _Atomic(size_t) atomic_size_t;
+
+typedef struct atomic_flag {
+ atomic_bool _Value;
+} atomic_flag;
+
+typedef enum memory_order {
+ memory_order_relaxed = __ATOMIC_RELAXED,
+ memory_order_consume = __ATOMIC_CONSUME,
+ memory_order_acquire = __ATOMIC_ACQUIRE,
+ memory_order_release = __ATOMIC_RELEASE,
+ memory_order_acq_rel = __ATOMIC_ACQ_REL,
+ memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+#define atomic_is_lock_free(obj) __atomic_is_lock_free(sizeof(*(obj)), 0)
+#define atomic_flag_test_and_set(obj) __atomic_test_and_set((obj), memory_order_seq_cst)
+#define atomic_flag_clear(obj) __atomic_clear((obj), memory_order_seq_cst)
+#define atomic_load(obj) __atomic_load_n((obj), memory_order_seq_cst)
+#define atomic_store(obj, desired) __atomic_store_n((obj), (desired), memory_order_seq_cst)
+#define atomic_exchange(obj, desired) __atomic_exchange_n((obj), (desired), memory_order_seq_cst)
+#define atomic_fetch_add(obj, arg) __atomic_fetch_add((obj), (arg), memory_order_seq_cst)
+#define atomic_fetch_sub(obj, arg) __atomic_fetch_sub((obj), (arg), memory_order_seq_cst)
+#define atomic_fetch_and(obj, arg) __atomic_fetch_and((obj), (arg), memory_order_seq_cst)
+#define atomic_fetch_or(obj, arg) __atomic_fetch_or((obj), (arg), memory_order_seq_cst)
+#define atomic_fetch_xor(obj, arg) __atomic_fetch_xor((obj), (arg), memory_order_seq_cst)
+
+#define atomic_signal_fence __atomic_signal_fence
+#define atomic_thread_fence __atomic_thread_fence
+#define atomic_flag_test_and_set_explicit __atomic_test_and_set
+#define atomic_flag_clear_explicit __atomic_clear
+#define atomic_load_explicit __atomic_load_n
+#define atomic_store_explicit __atomic_store_n
+#define atomic_exchange_explicit __atomic_exchange_n
+#define atomic_fetch_add_explicit __atomic_fetch_add
+#define atomic_fetch_sub_explicit __atomic_fetch_sub
+#define atomic_fetch_and_explicit __atomic_fetch_and
+#define atomic_fetch_or_explicit __atomic_fetch_or
+#define atomic_fetch_xor_explicit __atomic_fetch_xor
+
+#define atomic_compare_exchange_strong(obj, expected, desired) __atomic_compare_exchange_n((obj), (expected), (desired), false, memory_order_seq_cst, memory_order_seq_cst)
+#define atomic_compare_exchange_weak(obj, expected, desired) __atomic_compare_exchange_n((obj), (expected), (desired), true, memory_order_seq_cst, memory_order_seq_cst)
+#define atomic_compare_exchange_strong_explicit __atomic_compare_exchange_n
+#define atomic_compare_exchange_weak_explicit __atomic_compare_exchange_n
+
+#endif
+
+#endif /* !_STDATOMIC_H */
diff --git a/lib/libc/include/stddef.h b/lib/libc/include/stddef.h
index 8b81c5b..642f773 100644
--- a/lib/libc/include/stddef.h
+++ b/lib/libc/include/stddef.h
@@ -28,18 +28,157 @@
*/
#ifndef _STDDEF_H
-#define _STDDEF_H
+#define _STDDEF_H 1
-#include <bits/types.h>
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+#define __STDC_VERSION_STDDEF_H__ 202311L
+#endif
+
+/* Determine which definitions are needed */
+#if !defined(__need_NULL) && !defined(__need_nullptr_t) && \
+ !defined(__need_size_t) && !defined(__need_rsize_t) && \
+ !defined(__need_wchar_t) && !defined(__need_wint_t) && \
+ !defined(__need_ptrdiff_t) && !defined(__need_max_align_t) && \
+ !defined(__need_offsetof) && !defined(__need_unreachable)
+#define __need_NULL
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || defined(__cplusplus)
+#define __need_nullptr_t
+#endif
+#define __need_ptrdiff_t
+#define __need_size_t
+#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
+#define __need_rsize_t
+#endif
+#define __need_wchar_t
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || (defined(__cplusplus) && __cplusplus >= 201103L)
+#define __need_max_align_t
+#endif
+#define __need_offsetof
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+#define __need_unreachable
+#endif
+#endif
+/* NULL pointer constant */
+#ifdef __need_NULL
+#ifdef __cplusplus
#if __cplusplus >= 201103L
#define NULL nullptr
-#elif defined(__cplusplus)
+#else
#define NULL 0L
+#endif /* __cplusplus >= 201103L */
#else
-#define NULL ((void *) 0)
+#define NULL ((void *) 0)
+#endif /* __cplusplus */
+#undef __need_NULL
+#endif /* __need_NULL */
+
+/* nullptr_t type */
+#ifdef __need_nullptr_t
+#ifndef _NULLPTR_T
+#define _NULLPTR_T
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
+typedef typeof(nullptr) nullptr_t;
#endif
+#endif /* !_NULLPTR_T */
+#undef __need_nullptr_t
+#endif /* __need_nullptr_t */
+
+/* size_t type */
+#ifdef __need_size_t
+#ifndef _SIZE_T
+#define _SIZE_T
+#ifdef __SIZE_TYPE__
+typedef __SIZE_TYPE__ size_t;
+#else
+typedef long unsigned int size_t;
+#endif /* __SIZE_TYPE__ */
+#endif /* !_SIZE_T */
+#undef __need_size_t
+#endif /* __need_size_t */
+
+/* rsize_t type */
+#ifdef __need_rsize_t
+#ifndef _RSIZE_T
+#define _RSIZE_T
+#ifdef __SIZE_TYPE__
+typedef __SIZE_TYPE__ rsize_t;
+#else
+typedef long unsigned int rsize_t;
+#endif /* __SIZE_TYPE__ */
+#endif /* !_RSIZE_T */
+#undef __need_rsize_t
+#endif /* __need_rsize_t */
-typedef __size_t size_t;
+/* wchar_t type */
+#ifdef __need_wchar_t
+#ifndef _WCHAR_T
+#define _WCHAR_T
+#ifdef __WCHAR_TYPE__
+typedef __WCHAR_TYPE__ wchar_t;
+#else
+typedef int wchar_t;
+#endif /* __WCHAR_TYPE__ */
+#endif /* !_WCHAR_T */
+#undef __need_wchar_t
+#endif /* __need_wchar_t */
+
+/* wint_t type */
+#ifdef __need_wint_t
+#ifndef _WINT_T
+#define _WINT_T
+#ifdef __WINT_TYPE__
+typedef __WINT_TYPE__ wint_t;
+#else
+typedef unsigned int wint_t;
+#endif /* __WINT_TYPE__ */
+#endif /* !_WINT_T */
+#undef __need_wint_t
+#endif /* __need_wint_t */
+
+/* ptrdiff_t type */
+#ifdef __need_ptrdiff_t
+#ifndef _PTRDIFF_T
+#define _PTRDIFF_T
+#ifdef __PTRDIFF_TYPE__
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+#else
+typedef long int ptrdiff_t;
+#endif /* __PTRDIFF_TYPE__ */
+#endif /* !_PTRDIFF_T */
+#undef __need_ptrdiff_t
+#endif /* __need_ptrdiff_t */
+
+/* max_align_t type */
+#ifdef __need_max_align_t
+#if defined (_MSC_VER)
+typedef double max_align_t;
+#elif defined(__APPLE__)
+typedef long double max_align_t;
+#else
+typedef struct {
+ long long __longlong __attribute__((__aligned__(__alignof__(long long))));
+ long double __longdouble __attribute__((__aligned__(__alignof__(long double))));
+} max_align_t;
+#endif
+#undef __need_max_align_t
+#endif /* __need_max_align_t */
+
+/* offsetof() macro */
+#ifdef __need_offsetof
+#ifndef offsetof
+#define offsetof(type, member) __builtin_offsetof(type, member)
+#endif
+#undef __need_offsetof
+#endif /* __need_offsetof */
+
+/* unreachable() macro */
+#ifdef __need_unreachable
+/* C++ has std::unreachable() */
+#if !defined(__cplusplus) && !defined(unreachable)
+#define unreachable() __builtin_unreachable()
+#endif
+#undef __need_unreachable
+#endif /* __need_unreachable */
#endif /* !_STDDEF_H */
diff --git a/lib/libc/include/stdint.h b/lib/libc/include/stdint.h
index 9351933..7ea872d 100644
--- a/lib/libc/include/stdint.h
+++ b/lib/libc/include/stdint.h
@@ -30,32 +30,6 @@
#ifndef _STDINT_H
#define _STDINT_H
-#include <bits/types.h>
-
-typedef __uint8_t uint8_t;
-typedef __uint16_t uint16_t;
-typedef __uint32_t uint32_t;
-typedef __uint64_t uint64_t;
-typedef __size_t uintptr_t;
-
-typedef __int8_t int8_t;
-typedef __int16_t int16_t;
-typedef __int32_t int32_t;
-typedef __int64_t int64_t;
-
-#define INT8_MIN __INT8_MIN
-#define INT16_MIN __INT16_MIN
-#define INT32_MIN __INT32_MIN
-#define INT64_MIN __INT64_MIN
-
-#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
+#include <sys/types.h>
#endif /* !_STDINT_H */
diff --git a/lib/libc/include/stdio.h b/lib/libc/include/stdio.h
new file mode 100644
index 0000000..37931ce
--- /dev/null
+++ b/lib/libc/include/stdio.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _STDIO_H
+#define _STDIO_H 1
+
+#include <sys/cdefs.h>
+#define __need_NULL
+#define __need_size_t
+#include <stddef.h>
+#include <unistd.h>
+#define __need_va_list
+#include <stdarg.h>
+
+#if __STDC_VERSION__ >= 202311L
+#define __STDC_VERSION_STDIO_H__ 202311L
+#endif
+
+/* Buffering modes */
+#define _IOFBF 0 /* Fully buffered */
+#define _IOLBF 1 /* Line buffered */
+#define _IONBF 2 /* Unbuffered */
+
+/* Default buffer size */
+#define BUFSIZ 256
+
+/* End-Of-File indicator */
+#define EOF (-1)
+
+/* Spec says these should be defined as macros */
+#define stdin stdin
+#define stdout stdout
+#define stderr stderr
+
+/* File structure */
+typedef struct _IO_FILE {
+ int fd;
+ int buf_mode;
+} FILE;
+
+extern FILE *stdin;
+extern FILE *stdout;
+extern FILE *stderr;
+
+#define putc(c, stream) fputc((c), (stream))
+#define getc(stream) fgetc((stream))
+
+__BEGIN_DECLS
+
+size_t fread(void *__restrict ptr, size_t size, size_t n, FILE *__restrict stream);
+size_t fwrite(const void *__restrict ptr, size_t size, size_t n, FILE *__restrict stream);
+
+long ftell(FILE *stream);
+char *fgets(char *__restrict s, int size, FILE *__restrict stream);
+
+FILE *fopen(const char *__restrict path, const char *__restrict mode);
+int fseek(FILE *stream, long offset, int whence);
+int fclose(FILE *stream);
+
+int vsnprintf(char *s, size_t size, const char *fmt, va_list ap);
+int snprintf(char *s, size_t size, const char *fmt, ...);
+
+int printf(const char *__restrict fmt, ...);
+int fileno(FILE *stream);
+int fputc(int c, FILE *stream);
+
+int putchar(int c);
+int fgetc(FILE *stream);
+int getchar(void);
+
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+int fputs(const char *__restrict s, FILE *__restrict stream);
+#else
+int fputs(const char *s, FILE *stream);
+#endif
+int puts(const char *s);
+
+__END_DECLS
+
+#endif /* !_STDIO_H */
diff --git a/lib/libc/include/stdlib.h b/lib/libc/include/stdlib.h
new file mode 100644
index 0000000..b1de3f3
--- /dev/null
+++ b/lib/libc/include/stdlib.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _STDLIB_H
+#define _STDLIB_H 1
+
+/* For __dead */
+#include <sys/cdefs.h>
+
+/* Get specific definitions from stddef.h */
+#define __need_NULL
+#define __need_size_t
+#define __need_wchar_t
+#include <stddef.h>
+
+#if __STDC_VERSION__ >= 202311L
+#define __STDC_VERSION_STDLIB_H__ 202311L
+#endif
+
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+
+typedef struct {
+ int quot;
+ int rem;
+} div_t;
+
+#ifndef __ldiv_t_defined
+typedef struct {
+ long int quot;
+ long int rem;
+} ldiv_t;
+#define __ldiv_t_defined 1
+#endif /* !__ldiv_t_defined */
+
+#ifndef __lldiv_t_defined
+typedef struct {
+ long long int quot;
+ long long int rem;
+} lldiv_t;
+#define __lldiv_t_defined 1
+#endif /* !__lldiv_t_defined */
+
+__BEGIN_DECLS
+
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || (defined(__cplusplus) && __cplusplus >= 201103L)
+[[noreturn]] void abort(void);
+[[noreturn]] void exit(int status);
+[[noreturn]] void _Exit(int status);
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+_Noreturn void abort(void);
+_Noreturn void exit(int status);
+_Noreturn void _Exit(int status);
+#else
+__dead void abort(void);
+__dead void exit(int status);
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+__dead void _Exit(int status);
+#endif
+#endif
+
+void *malloc(size_t size);
+void *realloc(void *ptr, size_t size);
+void free(void *ptr);
+
+void srand(unsigned int r);
+int rand(void);
+
+__END_DECLS
+
+#endif /* !_STDLIB_H */
diff --git a/lib/libc/include/stdlib/errno.h b/lib/libc/include/stdlib/errno.h
new file mode 100644
index 0000000..98cb391
--- /dev/null
+++ b/lib/libc/include/stdlib/errno.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _ERRNO_BRIDGE_H_
+#define _ERRNO_BRIDGE_H_
+
+#if !defined(_POSIXSHIM)
+#include <ousi/errno.h>
+#else
+#include <sys/errno.h>
+#endif
+
+#endif /* _ERRNO_BRIDGE_H_ */
diff --git a/lib/libc/include/string.h b/lib/libc/include/string.h
new file mode 100644
index 0000000..4ab1e45
--- /dev/null
+++ b/lib/libc/include/string.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _STRING_H_
+#define _STRING_H_ 1
+
+#include <stddef.h>
+#include <stdint.h>
+
+size_t strlen(const char *s);
+char *strtok(char *s, const char *delim);
+char *strdup(const char *s);
+
+void *memset(void *dst, int c, size_t n);
+int memcmp(const void *s1, const void *s2, size_t n);
+
+char *itoa(int64_t value, char *buf, int base);
+void *memcpy(void *dest, const void *src, size_t n);
+int strcmp(const char *s1, const char *s2);
+int atoi(const char *s);
+
+#endif /* !_STRING_H_ */
diff --git a/lib/libc/include/time.h b/lib/libc/include/time.h
new file mode 100644
index 0000000..afb8adc
--- /dev/null
+++ b/lib/libc/include/time.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Hyra nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _TIME_H_
+#define _TIME_H_ 1
+
+#include <sys/time.h>
+
+int sleep(struct timespec *__restrict tsp, struct timespec *__restrict remp);
+
+#endif /* !_TIME_H_ */
diff --git a/lib/libc/include/unistd.h b/lib/libc/include/unistd.h
index c487d38..b9c9f5e 100644
--- a/lib/libc/include/unistd.h
+++ b/lib/libc/include/unistd.h
@@ -30,14 +30,35 @@
#ifndef _UNISTD_H
#define _UNISTD_H
+#include <sys/exec.h>
#include <sys/types.h>
#include <sys/cdefs.h>
+#include <stddef.h>
+
+#define F_OK 0
+
+/* lseek whence, follows Hyra ABI */
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
__BEGIN_DECLS
+int sysconf(int name);
+int setuid(uid_t new);
+
+uid_t getuid(void);
+char *getlogin(void);
+
ssize_t read(int fd, void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count);
+
int close(int fd);
+int access(const char *path, int mode);
+off_t lseek(int fildes, off_t offset, int whence);
+
+pid_t getpid(void);
+pid_t getppid(void);
__END_DECLS