summaryrefslogtreecommitdiffhomepage
path: root/dev/CompilerKit/utils/DylibHelpers.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:05:29 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 03:05:29 +0100
commitbbe2c77243c541ca7e0075149f5be3262eb89523 (patch)
treeae5d59d299344fd19584a2c3642bacd788e841d4 /dev/CompilerKit/utils/DylibHelpers.h
parentb5adf16a96b9cbb80c74cf30404ed5bcff03ac34 (diff)
feat! breaking changes on necti sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/CompilerKit/utils/DylibHelpers.h')
-rw-r--r--dev/CompilerKit/utils/DylibHelpers.h63
1 files changed, 0 insertions, 63 deletions
diff --git a/dev/CompilerKit/utils/DylibHelpers.h b/dev/CompilerKit/utils/DylibHelpers.h
deleted file mode 100644
index ab58fc7..0000000
--- a/dev/CompilerKit/utils/DylibHelpers.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ========================================
-
- Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license
-
-======================================== */
-
-#pragma once
-
-#include <CompilerKit/Defines.h>
-#include <dlfcn.h>
-#include <mutex>
-
-struct CompilerKitDylibTraits;
-
-typedef Int32 (*CompilerKitEntrypoint)(Int32 argc, Char const* argv[]);
-typedef VoidPtr CompilerKitDylib;
-
-struct CompilerKitDylibTraits final {
- CompilerKitDylib fDylib{nullptr};
- CompilerKitEntrypoint fEntrypoint{nullptr};
- std::mutex fMutex;
-
- CompilerKitDylibTraits& operator()(const Char* path, const Char* fEntrypoint) {
- std::lock_guard<std::mutex> lock(this->fMutex);
-
- if (!path || !fEntrypoint) return *this;
-
- if (this->fDylib) {
- dlclose(this->fDylib);
- this->fDylib = nullptr;
- }
-
- this->fDylib = dlopen(path, RTLD_LAZY);
-
- if (!this->fDylib) {
- return *this;
- }
-
- this->fEntrypoint = (CompilerKitEntrypoint) dlsym(this->fDylib, fEntrypoint);
-
- if (!this->fEntrypoint) {
- dlclose(this->fDylib);
- this->fDylib = nullptr;
-
- return *this;
- }
-
- return *this;
- }
-
- NECTI_COPY_DELETE(CompilerKitDylibTraits);
-
- CompilerKitDylibTraits() = default;
-
- ~CompilerKitDylibTraits() {
- if (this->fDylib) {
- dlclose(this->fDylib);
- this->fDylib = nullptr;
- }
-
- this->fEntrypoint = nullptr;
- }
-};