From 4cb29fbc2d20f20e9d605796b137b4b70363113a Mon Sep 17 00:00:00 2001 From: 0scar Date: Fri, 28 Jul 2023 16:32:58 +0200 Subject: Implement hotloading * This commit implements dltools.{c,h}: _A simple wrapper around libdl / dlfcn.h_ * Reload states when done initializing engine, if hotloading is enabled. * Adds general function types for state functions. --- include/engine/dltools.h | 14 ++++++++++++++ include/engine/state.h | 3 +++ 2 files changed, 17 insertions(+) create mode 100644 include/engine/dltools.h (limited to 'include') diff --git a/include/engine/dltools.h b/include/engine/dltools.h new file mode 100644 index 0000000..9306ae7 --- /dev/null +++ b/include/engine/dltools.h @@ -0,0 +1,14 @@ +#ifndef DLTOOLS_H +#define DLTOOLS_H + +/* Utility functions for handling runtime linked shared libraries */ +bool dynamic_library_close(void* shared_library); +void* dynamic_library_open(const char *library_path); +void* dynamic_library_reload(void* shared_library, const char *library_path); + +/* Returns the address of symbol in the provided shared_library handle. + * NULL on error*/ +void* dynamic_library_get_symbol(void* shared_library, const char *symbol); +char* dynamic_library_get_error(void); + +#endif diff --git a/include/engine/state.h b/include/engine/state.h index 402c701..cf486cc 100644 --- a/include/engine/state.h +++ b/include/engine/state.h @@ -20,4 +20,7 @@ void State_init(StateType type, memory *mem); void State_free(StateType type, memory *mem); StateType State_update(StateType type, memory *mem); +/* Reloads shared object file associated with state */ +bool State_reload(StateType type); + #endif -- cgit v1.3