shengine pre-release
shengine by mrsinho
|
Platform-specific shared library loading functions. More...
#include <dlfcn.h>
#include <stdint.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | ShApplicationHost |
Represents the host for a shared application. More... | |
Macros | |
#define | shLoadShared(path) dlopen(path, RTLD_LAZY) |
Macro to load a shared library on non-Windows platforms. | |
#define | shSharedLoadSymbol(handle, symbol) dlsym(handle, symbol) |
Macro to load a symbol from a shared library on non-Windows platforms. | |
#define | shSharedFree(handle) dlclose(handle) |
Macro to free a loaded shared library on non-Windows platforms. | |
#define | shSharedHostError(condition, msg, failure_expression) if ((int)(condition)) { printf("shsharedhost error: %s\n", msg); failure_expression; } |
Macro to handle errors in the shared host. | |
#define | shSharedRelease(p_shared) if ((p_shared) != NULL) { if (*(p_shared) != NULL) { shSharedFree(*(p_shared)); *(p_shared) = NULL; } } |
Releases the shared library. | |
Typedefs | |
typedef void * | ShSharedHandle |
Represents a handle to a loaded shared library. | |
typedef uint8_t() | ShApplicationFunc(void *) |
Represents the function signature for the application's main function. | |
typedef uint64_t() | ShApplicationThreadFunc(void *) |
Represents the function signature for a thread within the application. | |
typedef struct ShApplicationHost | ShApplicationHost |
Functions | |
uint64_t | shApplicationRun (void *p_engine, ShApplicationFunc *p_func) |
Runs a shared application. | |
uint8_t | shGetSharedApplication (const char *shared_name, const char *s_start, const char *s_update, const char *s_main_cmd_buffer, const char *s_main_renderpass, const char *s_frame_resize, const char *s_close, ShApplicationHost *p_application) |
Retrieves the shared application information. | |
Platform-specific shared library loading functions.
This file provides platform-specific macros and functions for loading shared libraries dynamically.
#define shLoadShared | ( | path | ) | dlopen(path, RTLD_LAZY) |
Macro to load a shared library on non-Windows platforms.
This macro uses the POSIX function dlopen
to load a shared library.
path | Path to the shared library. |
#define shSharedFree | ( | handle | ) | dlclose(handle) |
Macro to free a loaded shared library on non-Windows platforms.
This macro uses the POSIX function dlclose
to free a loaded shared library.
handle | Handle to the loaded shared library. |
#define shSharedHostError | ( | condition, | |
msg, | |||
failure_expression | |||
) | if ((int)(condition)) { printf("shsharedhost error: %s\n", msg); failure_expression; } |
Macro to handle errors in the shared host.
This macro prints an error message and executes a failure expression if a condition is true.
condition | The condition to check. |
msg | The error message. |
failure_expression | The expression to execute in case of failure. |
#define shSharedLoadSymbol | ( | handle, | |
symbol | |||
) | dlsym(handle, symbol) |
Macro to load a symbol from a shared library on non-Windows platforms.
This macro uses the POSIX function dlsym
to load a symbol from a shared library.
handle | Handle to the loaded shared library. |
symbol | Symbol name to load. |
#define shSharedRelease | ( | p_shared | ) | if ((p_shared) != NULL) { if (*(p_shared) != NULL) { shSharedFree(*(p_shared)); *(p_shared) = NULL; } } |
Releases the shared library.
This macro frees the loaded shared library if it is not NULL.
p_shared | A pointer to the shared library handle. |
ShApplicationFunc |
Represents the function signature for the application's main function.
It takes A pointer as argument to manage some data that the application may use.
typedef struct ShApplicationHost ShApplicationHost |
ShApplicationThreadFunc |
Represents the function signature for a thread within the application.
It takes A pointer as argument to manage some data that the application may use.
Represents a handle to a loaded shared library.
|
extern |
Runs a shared application.
This function runs the shared application by executing the provided application function.
p_engine | A pointer to the engine data. |
p_func | The application function to run. |
|
extern |
Retrieves the shared application information.
This function retrieves information about the shared application from the shared library.
shared_name | The name of the shared library. |
s_start | The symbol name for the start function. |
s_update | The symbol name for the update function. |
s_main_cmd_buffer | The symbol name for the main command buffer function. |
s_main_renderpass | The symbol name for the main render pass function. |
s_frame_resize | The symbol name for the frame resize function. |
s_close | The symbol name for the close function. |
p_application | A pointer to the application host structure to fill. |