aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/rtdl/include
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:00 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 17:28:32 -0500
commitbd5969fc876a10b18613302db7087ef3c40f18e1 (patch)
tree7c2b8619afe902abf99570df2873fbdf40a4d1a1 /lib/mlibc/options/rtdl/include
parenta95b38b1b92b172e6cc4e8e56a88a30cc65907b0 (diff)
lib: Add mlibc
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/rtdl/include')
-rw-r--r--lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp28
-rw-r--r--lib/mlibc/options/rtdl/include/mlibc/rtdl-config.hpp24
-rw-r--r--lib/mlibc/options/rtdl/include/mlibc/rtdl-sysdeps.hpp12
3 files changed, 64 insertions, 0 deletions
diff --git a/lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp b/lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp
new file mode 100644
index 0000000..135b461
--- /dev/null
+++ b/lib/mlibc/options/rtdl/include/mlibc/rtdl-abi.hpp
@@ -0,0 +1,28 @@
+#ifndef MLIBC_RTDL_ABI
+#define MLIBC_RTDL_ABI
+
+#include <stdint.h>
+
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__i386__) || defined(__riscv)
+
+struct __abi_tls_entry {
+ struct SharedObject *object;
+ size_t offset;
+};
+static_assert(sizeof(__abi_tls_entry) == sizeof(size_t) * 2, "Bad __abi_tls_entry size");
+
+extern "C" void *__dlapi_get_tls(struct __abi_tls_entry *);
+
+#else
+#error "Missing architecture specific code."
+#endif
+
+#if defined(__riscv)
+constexpr inline unsigned long TLS_DTV_OFFSET = 0x800;
+#elif defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
+constexpr inline unsigned long TLS_DTV_OFFSET = 0;
+#else
+#error "Missing architecture specific code."
+#endif
+
+#endif // MLIBC_RTDL_ABI
diff --git a/lib/mlibc/options/rtdl/include/mlibc/rtdl-config.hpp b/lib/mlibc/options/rtdl/include/mlibc/rtdl-config.hpp
new file mode 100644
index 0000000..4838880
--- /dev/null
+++ b/lib/mlibc/options/rtdl/include/mlibc/rtdl-config.hpp
@@ -0,0 +1,24 @@
+#ifndef MLIBC_RTDL_CONFIG
+#define MLIBC_RTDL_CONFIG
+
+namespace mlibc {
+
+struct RtdlConfig {
+ bool secureRequired;
+};
+
+}
+
+extern "C" const mlibc::RtdlConfig &__dlapi_get_config();
+
+#ifndef MLIBC_BUILDING_RTDL
+namespace mlibc {
+
+inline const RtdlConfig &rtdlConfig() {
+ return __dlapi_get_config();
+}
+
+}
+#endif
+
+#endif // MLIBC_RTDL_CONFIG
diff --git a/lib/mlibc/options/rtdl/include/mlibc/rtdl-sysdeps.hpp b/lib/mlibc/options/rtdl/include/mlibc/rtdl-sysdeps.hpp
new file mode 100644
index 0000000..c35271c
--- /dev/null
+++ b/lib/mlibc/options/rtdl/include/mlibc/rtdl-sysdeps.hpp
@@ -0,0 +1,12 @@
+#ifndef MLIBC_RTDL_SYSDEPS
+#define MLIBC_RTDL_SYSDEPS
+
+namespace [[gnu::visibility("hidden")]] mlibc {
+
+int sys_tcb_set(void *pointer);
+
+[[gnu::weak]] int sys_vm_readahead(void *pointer, size_t size);
+
+} // namespace mlibc
+
+#endif // MLIBC_RTDL_SYSDEPS