aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/internal/include/bits
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mlibc/options/internal/include/bits')
-rw-r--r--lib/mlibc/options/internal/include/bits/cpu_set.h13
-rw-r--r--lib/mlibc/options/internal/include/bits/ensure.h45
-rw-r--r--lib/mlibc/options/internal/include/bits/ether_addr.h10
-rw-r--r--lib/mlibc/options/internal/include/bits/inline-definition.h19
-rw-r--r--lib/mlibc/options/internal/include/bits/machine.h86
-rw-r--r--lib/mlibc/options/internal/include/bits/mbstate.h12
-rw-r--r--lib/mlibc/options/internal/include/bits/nl_item.h82
-rw-r--r--lib/mlibc/options/internal/include/bits/null.h16
-rw-r--r--lib/mlibc/options/internal/include/bits/off_t.h8
-rw-r--r--lib/mlibc/options/internal/include/bits/sigset_t.h25
-rw-r--r--lib/mlibc/options/internal/include/bits/size_t.h6
-rw-r--r--lib/mlibc/options/internal/include/bits/ssize_t.h15
-rw-r--r--lib/mlibc/options/internal/include/bits/threads.h79
-rw-r--r--lib/mlibc/options/internal/include/bits/types.h319
-rw-r--r--lib/mlibc/options/internal/include/bits/wchar.h9
-rw-r--r--lib/mlibc/options/internal/include/bits/wchar_t.h12
-rw-r--r--lib/mlibc/options/internal/include/bits/winsize.h13
-rw-r--r--lib/mlibc/options/internal/include/bits/wint_t.h6
18 files changed, 775 insertions, 0 deletions
diff --git a/lib/mlibc/options/internal/include/bits/cpu_set.h b/lib/mlibc/options/internal/include/bits/cpu_set.h
new file mode 100644
index 0000000..69f6923
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/cpu_set.h
@@ -0,0 +1,13 @@
+#ifndef _MLIBC_INTERNAL_CPU_SET_H
+#define _MLIBC_INTERNAL_CPU_SET_H
+
+typedef unsigned long __cpu_mask;
+
+#define CPU_SETSIZE 1024
+#define __NCPUBITS (8 * sizeof(__cpu_mask))
+
+typedef struct {
+ __cpu_mask __bits[CPU_SETSIZE / __NCPUBITS];
+} cpu_set_t;
+
+#endif /* _MLIBC_INTERNAL_CPU_SET_H */
diff --git a/lib/mlibc/options/internal/include/bits/ensure.h b/lib/mlibc/options/internal/include/bits/ensure.h
new file mode 100644
index 0000000..f75a2e9
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/ensure.h
@@ -0,0 +1,45 @@
+
+#ifndef MLIBC_ENSURE_H
+#define MLIBC_ENSURE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+void __ensure_fail(const char *assertion, const char *file, unsigned int line,
+ const char *function);
+
+void __ensure_warn(const char *assertion, const char *file, unsigned int line,
+ const char *function);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#define __ensure(assertion) do { if(!(assertion)) \
+ __ensure_fail(#assertion, __FILE__, __LINE__, __func__); } while(0)
+
+#define MLIBC_UNIMPLEMENTED() __ensure_fail("Functionality is not implemented", \
+ __FILE__, __LINE__, __func__)
+
+#define MLIBC_MISSING_SYSDEP() __ensure_warn("Library function fails due to missing sysdep", \
+ __FILE__, __LINE__, __func__)
+
+#define MLIBC_CHECK_OR_ENOSYS(sysdep, ret) ({ \
+ if (!(sysdep)) { \
+ __ensure_warn("Library function fails due to missing sysdep", \
+ __FILE__, __LINE__, __func__); \
+ errno = ENOSYS; \
+ return (ret); \
+ } \
+ sysdep; \
+ })
+
+#define MLIBC_STUB_BODY { MLIBC_UNIMPLEMENTED(); __builtin_unreachable(); }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MLIBC_ENSURE_H
+
diff --git a/lib/mlibc/options/internal/include/bits/ether_addr.h b/lib/mlibc/options/internal/include/bits/ether_addr.h
new file mode 100644
index 0000000..1631e98
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/ether_addr.h
@@ -0,0 +1,10 @@
+#ifndef MLIBC_ETHER_ADDR_H
+#define MLIBC_ETHER_ADDR_H
+
+#include <stdint.h>
+
+struct ether_addr {
+ uint8_t ether_addr_octet[6];
+} __attribute__((__packed__));
+
+#endif // MLIBC_ETHER_ADDR_H
diff --git a/lib/mlibc/options/internal/include/bits/inline-definition.h b/lib/mlibc/options/internal/include/bits/inline-definition.h
new file mode 100644
index 0000000..ec4c4da
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/inline-definition.h
@@ -0,0 +1,19 @@
+#ifndef MLIBC_INLINE_DEFINITION_H
+#define MLIBC_INLINE_DEFINITION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __MLIBC_EMIT_INLINE_DEFINITIONS
+#define __MLIBC_INLINE_DEFINITION
+#else
+#define __MLIBC_INLINE_DEFINITION __attribute__((__gnu_inline__)) extern __inline__
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MLIBC_INLINE_DEFINITION_H
+
diff --git a/lib/mlibc/options/internal/include/bits/machine.h b/lib/mlibc/options/internal/include/bits/machine.h
new file mode 100644
index 0000000..371a94b
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/machine.h
@@ -0,0 +1,86 @@
+
+#ifndef MLIBC_MACHINE_H
+#define MLIBC_MACHINE_H
+
+#include <stdint.h>
+
+#if defined (__i386__)
+struct __mlibc_jmpbuf_register_state {
+ uint32_t ebx;
+ uint32_t ebp;
+ uint32_t esi;
+ uint32_t edi;
+ uint32_t esp;
+ uint32_t eip;
+};
+#elif defined (__x86_64__)
+struct __mlibc_jmpbuf_register_state {
+ uint64_t rbx;
+ uint64_t rbp;
+ uint64_t r12;
+ uint64_t r13;
+ uint64_t r14;
+ uint64_t r15;
+ uint64_t rsp;
+ uint64_t rip;
+};
+#elif defined (__aarch64__)
+struct __mlibc_jmpbuf_register_state {
+ uint64_t x19;
+ uint64_t x20;
+ uint64_t x21;
+ uint64_t x22;
+ uint64_t x23;
+ uint64_t x24;
+ uint64_t x25;
+ uint64_t x26;
+ uint64_t x27;
+ uint64_t x28;
+ uint64_t x29;
+ uint64_t x30;
+ uint64_t sp;
+ uint64_t pad;
+ uint64_t d8;
+ uint64_t d9;
+ uint64_t d10;
+ uint64_t d11;
+ uint64_t d12;
+ uint64_t d13;
+ uint64_t d14;
+ uint64_t d15;
+};
+#elif defined (__riscv) && __riscv_xlen == 64
+struct __mlibc_jmpbuf_register_state {
+ uint64_t ra;
+ uint64_t s0;
+ uint64_t s1;
+ uint64_t s2;
+ uint64_t s3;
+ uint64_t s4;
+ uint64_t s5;
+ uint64_t s6;
+ uint64_t s7;
+ uint64_t s8;
+ uint64_t s9;
+ uint64_t s10;
+ uint64_t s11;
+ uint64_t sp;
+ double fs0;
+ double fs1;
+ double fs2;
+ double fs3;
+ double fs4;
+ double fs5;
+ double fs6;
+ double fs7;
+ double fs8;
+ double fs9;
+ double fs10;
+ double fs11;
+};
+#else
+# error "Missing architecture specific code"
+#endif
+
+#endif // MLIBC_MACHINE_H
+
diff --git a/lib/mlibc/options/internal/include/bits/mbstate.h b/lib/mlibc/options/internal/include/bits/mbstate.h
new file mode 100644
index 0000000..2bfb3eb
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/mbstate.h
@@ -0,0 +1,12 @@
+#ifndef MLIBC_MBSTATE_H
+#define MLIBC_MBSTATE_H
+
+struct __mlibc_mbstate {
+ short __progress;
+ short __shift;
+ unsigned int __cpoint;
+};
+
+#define __MLIBC_MBSTATE_INITIALIZER {0, 0, 0}
+
+#endif // MLIBC_MBSTATE_H
diff --git a/lib/mlibc/options/internal/include/bits/nl_item.h b/lib/mlibc/options/internal/include/bits/nl_item.h
new file mode 100644
index 0000000..dc882dc
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/nl_item.h
@@ -0,0 +1,82 @@
+
+#ifndef _NL_ITEM_H
+#define _NL_ITEM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int nl_item;
+
+#define ABDAY_1 0x60000
+#define ABDAY_2 0x60001
+#define ABDAY_3 0x60002
+#define ABDAY_4 0x60003
+#define ABDAY_5 0x60004
+#define ABDAY_6 0x60005
+#define ABDAY_7 0x60006
+
+#define DAY_1 0x60007
+#define DAY_2 0x60008
+#define DAY_3 0x60009
+#define DAY_4 0x6000A
+#define DAY_5 0x6000B
+#define DAY_6 0x6000C
+#define DAY_7 0x6000D
+
+#define ABMON_1 0x6000E
+#define ABMON_2 0x6000F
+#define ABMON_3 0x60010
+#define ABMON_4 0x60011
+#define ABMON_5 0x60012
+#define ABMON_6 0x60013
+#define ABMON_7 0x60014
+#define ABMON_8 0x60015
+#define ABMON_9 0x60016
+#define ABMON_10 0x60017
+#define ABMON_11 0x60018
+#define ABMON_12 0x60019
+
+#define MON_1 0x6001A
+#define MON_2 0x6001B
+#define MON_3 0x6001C
+#define MON_4 0x6001D
+#define MON_5 0x6001E
+#define MON_6 0x6001F
+#define MON_7 0x60020
+#define MON_8 0x60021
+#define MON_9 0x60022
+#define MON_10 0x60023
+#define MON_11 0x60024
+#define MON_12 0x60025
+
+#define AM_STR 0x60026
+#define PM_STR 0x60027
+
+#define D_T_FMT 0x60028
+#define D_FMT 0x60029
+#define T_FMT 0x6002A
+#define T_FMT_AMPM 0x6002B
+
+#define ERA 0x6002C
+#define ERA_D_FMT 0x6002D
+#define ALT_DIGITS 0x6002E
+#define ERA_D_T_FMT 0x6002F
+#define ERA_T_FMT 0x60030
+
+#define CODESET 0x30000
+
+#define CRNCYSTR 0x40000
+
+#define RADIXCHAR 0x50000
+#define THOUSEP 0x50001
+
+#define YESEXPR 0x70000
+#define NOEXPR 0x70001
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _NL_ITEM_H
+
diff --git a/lib/mlibc/options/internal/include/bits/null.h b/lib/mlibc/options/internal/include/bits/null.h
new file mode 100644
index 0000000..7d3fa7b
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/null.h
@@ -0,0 +1,16 @@
+
+#ifndef MLIBC_NULL_H
+#define MLIBC_NULL_H
+
+#ifdef NULL
+#undef NULL
+#endif
+
+#ifndef __cplusplus
+# define NULL ((void *)0)
+#else
+# define NULL 0
+#endif
+
+#endif // MLIBC_NULL_H
+
diff --git a/lib/mlibc/options/internal/include/bits/off_t.h b/lib/mlibc/options/internal/include/bits/off_t.h
new file mode 100644
index 0000000..929fae9
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/off_t.h
@@ -0,0 +1,8 @@
+#ifndef MLIBC_OFF_T_H
+#define MLIBC_OFF_T_H
+
+// TODO: use something like int64_t instead?
+typedef long off_t;
+typedef long off64_t;
+
+#endif // MLIBC_OFF_T_H
diff --git a/lib/mlibc/options/internal/include/bits/sigset_t.h b/lib/mlibc/options/internal/include/bits/sigset_t.h
new file mode 100644
index 0000000..bb86848
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/sigset_t.h
@@ -0,0 +1,25 @@
+#ifndef MLIBC_BITS_SIGSET_T_H
+#define MLIBC_BITS_SIGSET_T_H
+
+#include <abi-bits/signal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef __MLIBC_ABI_ONLY
+
+// functions to manage sigset_t
+int sigemptyset(sigset_t *);
+int sigfillset(sigset_t *);
+int sigaddset(sigset_t *, int);
+int sigdelset(sigset_t *, int);
+int sigismember(const sigset_t *set, int sig);
+
+#endif /* !__MLIBC_ABI_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //MLIBC_BITS_SIGSET_T_H
diff --git a/lib/mlibc/options/internal/include/bits/size_t.h b/lib/mlibc/options/internal/include/bits/size_t.h
new file mode 100644
index 0000000..46d7486
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/size_t.h
@@ -0,0 +1,6 @@
+#ifndef MLIBC_SIZE_T_H
+#define MLIBC_SIZE_T_H
+
+typedef __SIZE_TYPE__ size_t;
+
+#endif // MLIBC_SIZE_T_H
diff --git a/lib/mlibc/options/internal/include/bits/ssize_t.h b/lib/mlibc/options/internal/include/bits/ssize_t.h
new file mode 100644
index 0000000..c450233
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/ssize_t.h
@@ -0,0 +1,15 @@
+
+#ifndef MLIBC_SSIZE_T_H
+#define MLIBC_SSIZE_T_H
+
+// TODO: use ptrdiff_t instead?
+#if __UINTPTR_MAX__ == __UINT64_MAX__
+typedef long ssize_t;
+#elif __UINTPTR_MAX__ == __UINT32_MAX__
+typedef int ssize_t;
+#else
+#error "unsupported architecture"
+#endif
+
+#endif // MLIBC_SSIZE_T_H
+
diff --git a/lib/mlibc/options/internal/include/bits/threads.h b/lib/mlibc/options/internal/include/bits/threads.h
new file mode 100644
index 0000000..3feb4c3
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/threads.h
@@ -0,0 +1,79 @@
+#ifndef _INTERNAL_THREADS_H
+#define _INTERNAL_THREADS_H
+
+#include <abi-bits/clockid_t.h>
+#include <bits/size_t.h>
+#include <bits/cpu_set.h>
+#include <bits/sigset_t.h>
+
+// values for pthread_attr_{get,set}detachstate().
+#define __MLIBC_THREAD_CREATE_JOINABLE 0
+#define __MLIBC_THREAD_CREATE_DETACHED 1
+
+// values for pthread_mutexattr_{get,set}type().
+#define __MLIBC_THREAD_MUTEX_DEFAULT 0
+#define __MLIBC_THREAD_MUTEX_NORMAL 0
+#define __MLIBC_THREAD_MUTEX_ERRORCHECK 1
+#define __MLIBC_THREAD_MUTEX_RECURSIVE 2
+
+// values for pthread_mutexattr_{get,set}pshared().
+#define __MLIBC_THREAD_PROCESS_PRIVATE 0
+#define __MLIBC_THREAD_PROCESS_SHARED 1
+
+// values for pthread_mutexattr_{get,set}robust().
+#define __MLIBC_THREAD_MUTEX_STALLED 0
+#define __MLIBC_THREAD_MUTEX_ROBUST 1
+
+// Values for pthread_mutexattr_{get,set}protocol()
+#define __MLIBC_THREAD_PRIO_NONE 0
+#define __MLIBC_THREAD_PRIO_INHERIT 1
+#define __MLIBC_THREAD_PRIO_PROTECT 2
+
+struct sched_param {
+ int sched_priority;
+};
+
+struct __mlibc_thread_data;
+
+struct __mlibc_threadattr {
+ size_t __mlibc_guardsize;
+ size_t __mlibc_stacksize;
+ void *__mlibc_stackaddr;
+ int __mlibc_detachstate;
+ int __mlibc_scope;
+ int __mlibc_inheritsched;
+ struct sched_param __mlibc_schedparam;
+ int __mlibc_schedpolicy;
+ cpu_set_t *__mlibc_cpuset;
+ size_t __mlibc_cpusetsize;
+ sigset_t __mlibc_sigmask;
+ int __mlibc_sigmaskset;
+};
+
+struct __mlibc_mutex {
+ unsigned int __mlibc_state;
+ unsigned int __mlibc_recursion;
+ unsigned int __mlibc_flags;
+ int __mlibc_prioceiling;
+};
+
+struct __mlibc_mutexattr {
+ int __mlibc_type;
+ int __mlibc_robust;
+ int __mlibc_protocol;
+ int __mlibc_pshared;
+ int __mlibc_prioceiling;
+};
+
+struct __mlibc_cond {
+ unsigned int __mlibc_seq;
+ unsigned int __mlibc_flags;
+ clockid_t __mlibc_clock;
+};
+
+struct __mlibc_condattr {
+ int __mlibc_pshared;
+ clockid_t __mlibc_clock;
+};
+
+#endif /* _INTERNAL_THREADS_H */
diff --git a/lib/mlibc/options/internal/include/bits/types.h b/lib/mlibc/options/internal/include/bits/types.h
new file mode 100644
index 0000000..935c5e0
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/types.h
@@ -0,0 +1,319 @@
+#ifndef _MLIBC_INTERNAL_TYPES_H
+#define _MLIBC_INTERNAL_TYPES_H
+
+typedef __UINT8_TYPE__ __mlibc_uint8;
+typedef __UINT16_TYPE__ __mlibc_uint16;
+typedef __UINT32_TYPE__ __mlibc_uint32;
+typedef __UINT64_TYPE__ __mlibc_uint64;
+
+typedef __INT8_TYPE__ __mlibc_int8;
+typedef __INT16_TYPE__ __mlibc_int16;
+typedef __INT32_TYPE__ __mlibc_int32;
+typedef __INT64_TYPE__ __mlibc_int64;
+
+// Clang and GCC have different mechanisms for INT32_C and friends.
+#ifdef __clang__
+# define __MLIBC_C_EXPAND_JOIN(x, suffix) x ## suffix
+# define __MLIBC_C_JOIN(x, suffix) __MLIBC_C_EXPAND_JOIN(x, suffix)
+
+# define __MLIBC_INT8_C(x) __MLIBC_C_JOIN(x, __INT8_C_SUFFIX__)
+# define __MLIBC_INT16_C(x) __MLIBC_C_JOIN(x, __INT16_C_SUFFIX__)
+# define __MLIBC_INT32_C(x) __MLIBC_C_JOIN(x, __INT32_C_SUFFIX__)
+# define __MLIBC_INT64_C(x) __MLIBC_C_JOIN(x, __INT64_C_SUFFIX__)
+
+# define __MLIBC_UINT8_C(x) __MLIBC_C_JOIN(x, __UINT8_C_SUFFIX__)
+# define __MLIBC_UINT16_C(x) __MLIBC_C_JOIN(x, __UINT16_C_SUFFIX__)
+# define __MLIBC_UINT32_C(x) __MLIBC_C_JOIN(x, __UINT32_C_SUFFIX__)
+# define __MLIBC_UINT64_C(x) __MLIBC_C_JOIN(x, __UINT64_C_SUFFIX__)
+
+# define __MLIBC_INTMAX_C(x) __MLIBC_C_JOIN(x, __INTMAX_C_SUFFIX__)
+# define __MLIBC_UINTMAX_C(x) __MLIBC_C_JOIN(x, __UINTMAX_C_SUFFIX__)
+#else
+# define __MLIBC_INT8_C(x) __INT8_C(x)
+# define __MLIBC_INT16_C(x) __INT16_C(x)
+# define __MLIBC_INT32_C(x) __INT32_C(x)
+# define __MLIBC_INT64_C(x) __INT64_C(x)
+
+# define __MLIBC_UINT8_C(x) __UINT8_C(x)
+# define __MLIBC_UINT16_C(x) __UINT16_C(x)
+# define __MLIBC_UINT32_C(x) __UINT32_C(x)
+# define __MLIBC_UINT64_C(x) __UINT64_C(x)
+
+# define __MLIBC_INTMAX_C(x) __INTMAX_C(x)
+# define __MLIBC_UINTMAX_C(x) __UINTMAX_C(x)
+#endif
+
+#define __MLIBC_INT8_MAX __INT8_MAX__
+#define __MLIBC_INT16_MAX __INT16_MAX__
+#define __MLIBC_INT32_MAX __INT32_MAX__
+#define __MLIBC_INT64_MAX __INT64_MAX__
+
+#define __MLIBC_INT8_MIN (-__MLIBC_INT8_MAX - 1)
+#define __MLIBC_INT16_MIN (-__MLIBC_INT16_MAX - 1)
+#define __MLIBC_INT32_MIN (-__MLIBC_INT32_MAX - 1)
+#define __MLIBC_INT64_MIN (-__MLIBC_INT64_MAX - 1)
+
+#define __MLIBC_UINT8_MAX __UINT8_MAX__
+#define __MLIBC_UINT16_MAX __UINT16_MAX__
+#define __MLIBC_UINT32_MAX __UINT32_MAX__
+#define __MLIBC_UINT64_MAX __UINT64_MAX__
+
+// Fast types (signed).
+
+#if defined (__i386__)
+
+typedef __mlibc_int8 __mlibc_int_fast8;
+#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
+#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
+#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
+
+typedef __mlibc_int32 __mlibc_int_fast16;
+#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT32_C(x)
+#define __MLIBC_INT_FAST16_MAX __MLIBC_INT32_MAX
+#define __MLIBC_INT_FAST16_MIN __MLIBC_INT32_MIN
+
+typedef __mlibc_int32 __mlibc_int_fast32;
+#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT32_C(x)
+#define __MLIBC_INT_FAST32_MAX __MLIBC_INT32_MAX
+#define __MLIBC_INT_FAST32_MIN __MLIBC_INT32_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast64;
+#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
+
+#elif defined (__x86_64__)
+
+typedef __mlibc_int8 __mlibc_int_fast8;
+#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
+#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
+#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast16;
+#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST16_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST16_MIN __MLIBC_INT64_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast32;
+#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST32_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST32_MIN __MLIBC_INT64_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast64;
+#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
+
+#elif defined (__aarch64__)
+
+typedef __mlibc_int8 __mlibc_int_fast8;
+#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
+#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
+#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast16;
+#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST16_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST16_MIN __MLIBC_INT64_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast32;
+#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST32_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST32_MIN __MLIBC_INT64_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast64;
+#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
+
+#elif defined (__riscv) && __riscv_xlen == 64
+
+typedef __mlibc_int8 __mlibc_int_fast8;
+#define __MLIBC_INT_FAST8_C(x) __MLIBC_INT8_C(x)
+#define __MLIBC_INT_FAST8_MAX __MLIBC_INT8_MAX
+#define __MLIBC_INT_FAST8_MIN __MLIBC_INT8_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast16;
+#define __MLIBC_INT_FAST16_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST16_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST16_MIN __MLIBC_INT64_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast32;
+#define __MLIBC_INT_FAST32_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST32_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST32_MIN __MLIBC_INT64_MIN
+
+typedef __mlibc_int64 __mlibc_int_fast64;
+#define __MLIBC_INT_FAST64_C(x) __MLIBC_INT64_C(x)
+#define __MLIBC_INT_FAST64_MAX __MLIBC_INT64_MAX
+#define __MLIBC_INT_FAST64_MIN __MLIBC_INT64_MIN
+
+#else
+# error "Missing architecture specific code"
+#endif
+
+// Fast types (unsigned).
+
+#if defined (__i386__)
+
+typedef __mlibc_uint8 __mlibc_uint_fast8;
+#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
+#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
+#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
+
+typedef __mlibc_uint32 __mlibc_uint_fast16;
+#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT32_C(x)
+#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT32_MAX
+#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT32_MIN
+
+typedef __mlibc_uint32 __mlibc_uint_fast32;
+#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT32_C(x)
+#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT32_MAX
+#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT32_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast64;
+#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
+
+#elif defined (__x86_64__)
+
+typedef __mlibc_uint8 __mlibc_uint_fast8;
+#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
+#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
+#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast16;
+#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT64_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast32;
+#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT64_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast64;
+#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
+
+#elif defined (__aarch64__)
+
+typedef __mlibc_uint8 __mlibc_uint_fast8;
+#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
+#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
+#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast16;
+#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT64_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast32;
+#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT64_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast64;
+#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
+
+#elif defined (__riscv) && __riscv_xlen == 64
+
+typedef __mlibc_uint8 __mlibc_uint_fast8;
+#define __MLIBC_UINT_FAST8_C(x) __MLIBC_UINT8_C(x)
+#define __MLIBC_UINT_FAST8_MAX __MLIBC_UINT8_MAX
+#define __MLIBC_UINT_FAST8_MIN __MLIBC_UINT8_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast16;
+#define __MLIBC_UINT_FAST16_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST16_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST16_MIN __MLIBC_UINT64_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast32;
+#define __MLIBC_UINT_FAST32_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST32_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST32_MIN __MLIBC_UINT64_MIN
+
+typedef __mlibc_uint64 __mlibc_uint_fast64;
+#define __MLIBC_UINT_FAST64_C(x) __MLIBC_UINT64_C(x)
+#define __MLIBC_UINT_FAST64_MAX __MLIBC_UINT64_MAX
+#define __MLIBC_UINT_FAST64_MIN __MLIBC_UINT64_MIN
+
+#else
+# error "Missing architecture specific code"
+#endif
+
+// Special types.
+
+typedef __INTMAX_TYPE__ __mlibc_intmax;
+typedef __INTPTR_TYPE__ __mlibc_intptr;
+typedef __PTRDIFF_TYPE__ __mlibc_ptrdiff;
+#define __MLIBC_INTMAX_MAX __INTMAX_MAX__
+#define __MLIBC_INTMAX_MIN (-__INTMAX_MAX__ - 1)
+#define __MLIBC_INTPTR_MAX __INTPTR_MAX__
+#define __MLIBC_INTPTR_MIN (-__INTPTR_MAX__ - 1)
+#define __MLIBC_PTRDIFF_MAX __PTRDIFF_MAX__
+#define __MLIBC_PTRDIFF_MIN (-__PTRDIFF_MAX__ - 1)
+
+typedef __UINTMAX_TYPE__ __mlibc_uintmax;
+typedef __UINTPTR_TYPE__ __mlibc_uintptr;
+typedef __SIZE_TYPE__ __mlibc_size;
+#define __MLIBC_UINTMAX_MAX __UINTMAX_MAX__
+#define __MLIBC_UINTPTR_MAX __UINTPTR_MAX__
+#define __MLIBC_SIZE_MAX __SIZE_MAX__
+
+// Other limits.
+
+#define __MLIBC_WCHAR_MAX __WCHAR_MAX__
+#define __MLIBC_WCHAR_MIN __WCHAR_MIN__
+
+#define __MLIBC_WINT_MAX __WINT_MAX__
+#define __MLIBC_WINT_MIN __WINT_MIN__
+
+#define __MLIBC_SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
+#define __MLIBC_SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__
+
+// ----------------------------------------------------------------------------
+// Sanity checking. Make sure that we agree with the compiler's ABI.
+// ----------------------------------------------------------------------------
+
+#if defined(__cpp_static_assert)
+# define __MLIBC_STATIC_ASSERT(c, text) static_assert(c, text)
+#elif !defined(__cplusplus)
+# define __MLIBC_STATIC_ASSERT(c, text) _Static_assert(c, text)
+#else
+# define __MLIBC_STATIC_ASSERT(c, text)
+#endif
+
+#define __MLIBC_CHECK_TYPE(T1, T2) __MLIBC_STATIC_ASSERT(sizeof(T1) == sizeof(T2),\
+ #T1 " != " #T2);
+
+// Least-width.
+__MLIBC_CHECK_TYPE(__mlibc_int8, __INT_LEAST8_TYPE__);
+__MLIBC_CHECK_TYPE(__mlibc_int16, __INT_LEAST16_TYPE__);
+__MLIBC_CHECK_TYPE(__mlibc_int32, __INT_LEAST32_TYPE__);
+__MLIBC_CHECK_TYPE(__mlibc_int64, __INT_LEAST64_TYPE__);
+
+__MLIBC_CHECK_TYPE(__mlibc_uint8, __UINT_LEAST8_TYPE__);
+__MLIBC_CHECK_TYPE(__mlibc_uint16, __UINT_LEAST16_TYPE__);
+__MLIBC_CHECK_TYPE(__mlibc_uint32, __UINT_LEAST32_TYPE__);
+__MLIBC_CHECK_TYPE(__mlibc_uint64, __UINT_LEAST64_TYPE__);
+
+// Fast-width.
+// Unfortunately, GCC and Clang disagree about fast types.
+#ifndef __clang__
+ __MLIBC_CHECK_TYPE(__mlibc_int_fast8, __INT_FAST8_TYPE__);
+ __MLIBC_CHECK_TYPE(__mlibc_int_fast16, __INT_FAST16_TYPE__);
+ __MLIBC_CHECK_TYPE(__mlibc_int_fast32, __INT_FAST32_TYPE__);
+ __MLIBC_CHECK_TYPE(__mlibc_int_fast64, __INT_FAST64_TYPE__);
+
+ __MLIBC_CHECK_TYPE(__mlibc_uint_fast8, __UINT_FAST8_TYPE__);
+ __MLIBC_CHECK_TYPE(__mlibc_uint_fast16, __UINT_FAST16_TYPE__);
+ __MLIBC_CHECK_TYPE(__mlibc_uint_fast32, __UINT_FAST32_TYPE__);
+ __MLIBC_CHECK_TYPE(__mlibc_uint_fast64, __UINT_FAST64_TYPE__);
+#endif
+
+#endif // _MLIBC_INTERNAL_TYPES_H
diff --git a/lib/mlibc/options/internal/include/bits/wchar.h b/lib/mlibc/options/internal/include/bits/wchar.h
new file mode 100644
index 0000000..a422ef7
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/wchar.h
@@ -0,0 +1,9 @@
+#ifndef MLIBC_WCHAR_H
+#define MLIBC_WCHAR_H
+
+#include <bits/types.h>
+
+#define WCHAR_MAX __MLIBC_WCHAR_MAX
+#define WCHAR_MIN __MLIBC_WCHAR_MIN
+
+#endif // MLIBC_WCHAR_H
diff --git a/lib/mlibc/options/internal/include/bits/wchar_t.h b/lib/mlibc/options/internal/include/bits/wchar_t.h
new file mode 100644
index 0000000..4eb4e9c
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/wchar_t.h
@@ -0,0 +1,12 @@
+
+#ifndef MLIBC_WCHAR_T_H
+#define MLIBC_WCHAR_T_H
+
+#ifndef __cplusplus
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+#endif
+
+#endif // MLIBC_WCHAR_T_H
+
diff --git a/lib/mlibc/options/internal/include/bits/winsize.h b/lib/mlibc/options/internal/include/bits/winsize.h
new file mode 100644
index 0000000..7b3006a
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/winsize.h
@@ -0,0 +1,13 @@
+
+#ifndef MLIBC_WINSIZE_H
+#define MLIBC_WINSIZE_H
+
+struct winsize {
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
+};
+
+#endif // MLIBC_WINSIZE_H
+
diff --git a/lib/mlibc/options/internal/include/bits/wint_t.h b/lib/mlibc/options/internal/include/bits/wint_t.h
new file mode 100644
index 0000000..b4f57bf
--- /dev/null
+++ b/lib/mlibc/options/internal/include/bits/wint_t.h
@@ -0,0 +1,6 @@
+#ifndef MLIBC_WINT_T_H
+#define MLIBC_WINT_T_H
+
+typedef __WINT_TYPE__ wint_t;
+
+#endif // MLIBC_WINT_T_H