From 3cf50b077139b42c98943d5b48f9084ea9c31f7e Mon Sep 17 00:00:00 2001 From: Hunter Date: Fri, 21 Feb 2025 18:07:28 -0500 Subject: [PATCH] cmake config --- CMakeLists.txt | 10 ++++++++++ include/dlopen.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 include/dlopen.h diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3942e5b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.14..3.31 FATAL_ERROR) + +project(Hotwire + VERSION 1 + LANGUAGES C) + +add_library(hotwire src/dlopen.c) +add_library(hotwire::Hotwire ALIAS hotwire) + +target_include_directories(hotwire PUBLIC include) diff --git a/include/dlopen.h b/include/dlopen.h new file mode 100644 index 0000000..2e68778 --- /dev/null +++ b/include/dlopen.h @@ -0,0 +1,42 @@ +#pragma once +#include + +#if defined(__APPLE__) +#include +#endif + +#if defined(__linux__) +#include +#endif + +#if defined(_WIN32) +#include +#include +#endif + +// Platform specific code functions + +#if defined(_WIN32) +void hw_platform_win32_get_last_error(LPTSTR lpszFunction); +#endif + +enum hotwire_status_code { Failed, Success, NoPlatform }; + +struct hotwire_dll_t { +#if defined(__linux__) || defined(__APPLE__) + void *dll_handle; +#endif + +#if defined(_WIN32) + HINSTANCE dll_handle; +#endif +}; + +// Function arguments are based off the dlopen() api on POSIX based operating +// systems Loads dll from library +struct hotwire_dll_t hw_dlopen(const char *file, int flags); + +// Loads symbol from DLL +void *hw_dlsym(struct hotwire_dll_t dll, const char *symbol); + +enum hotwire_status_code hw_dlclose(struct hotwire_dll_t handle);