34#if defined(INFIX_OS_WINDOWS)
76#if defined(INFIX_OS_WINDOWS)
79 lib->
handle = LoadLibraryA(path);
87 lib->
handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
91 if (lib->
handle ==
nullptr) {
92#if defined(INFIX_OS_WINDOWS)
119#if defined(INFIX_OS_WINDOWS)
122 FreeLibrary((HMODULE)lib->
handle);
145 if (lib ==
nullptr || lib->
handle ==
nullptr || symbol_name ==
nullptr)
148#if defined(INFIX_OS_WINDOWS)
151 return (
void *)GetProcAddress((HMODULE)lib->
handle, symbol_name);
154 return dlsym(lib->
handle, symbol_name);
171 const char * symbol_name,
172 const char * type_signature,
174 if (buffer ==
nullptr)
179 if (symbol_addr ==
nullptr) {
214 const char * symbol_name,
215 const char * type_signature,
217 if (buffer ==
nullptr)
222 if (symbol_addr ==
nullptr) {
infix_arena_t * arena
Definition 005_layouts.c:57
infix_status status
Definition 103_unions.c:74
#define c23_nodiscard
Definition compat_c23.h:93
@ INFIX_CODE_SYMBOL_NOT_FOUND
The requested symbol could not be found within the lib.
Definition infix.h:1083
@ INFIX_CODE_LIBRARY_LOAD_FAILED
Definition infix.h:1084
@ INFIX_CODE_OUT_OF_MEMORY
Failure to allocate memory. Likely due to lack of system resources.
Definition infix.h:1061
@ INFIX_CATEGORY_ALLOCATION
An error related to memory allocation.
Definition infix.h:1042
@ INFIX_CATEGORY_GENERAL
A general or miscellaneous error.
Definition infix.h:1041
c23_nodiscard infix_status infix_write_global(infix_library_t *lib, const char *symbol_name, const char *type_signature, void *buffer)
Writes a value to a global variable in a loaded library.
Definition loader.c:213
c23_nodiscard infix_status infix_read_global(infix_library_t *lib, const char *symbol_name, const char *type_signature, void *buffer)
Reads the value of a global variable from a loaded library.
Definition loader.c:170
c23_nodiscard infix_status infix_type_from_signature(infix_type **, infix_arena_t **, const char *, infix_registry_t *)
Parses a signature string representing a single data type.
Definition signature.c:1090
void infix_library_close(infix_library_t *lib)
Closes a dynamic library handle and unloads it.
Definition loader.c:113
c23_nodiscard void * infix_library_get_symbol(infix_library_t *lib, const char *symbol_name)
Retrieves the memory address of a symbol (function or global variable).
Definition loader.c:144
c23_nodiscard infix_library_t * infix_library_open(const char *path)
Opens a dynamic library and returns a handle to it.
Definition loader.c:65
#define infix_free
A macro for the memory deallocation function.
Definition infix.h:280
void infix_arena_destroy(infix_arena_t *)
Frees an entire memory arena and all objects allocated within it.
Definition arena.c:68
#define infix_memcpy
A macro for copying memory from a source to a destination pointer.
Definition infix.h:290
#define infix_malloc
A macro for the memory allocation function used by the library.
Definition infix.h:250
infix_status
An enumeration of all possible success or failure codes from the public API.
Definition infix.h:351
@ INFIX_SUCCESS
The operation completed successfully.
Definition infix.h:352
@ INFIX_ERROR_INVALID_ARGUMENT
An invalid argument was provided to a function.
Definition infix.h:354
Declarations for internal-only functions, types, and constants.
void _infix_set_error(infix_error_category_t, infix_error_code_t, size_t)
Sets the thread-local error details for a library-internal error.
Definition error.c:44
void _infix_set_system_error(infix_error_category_t, infix_error_code_t, long, const char *)
Sets the thread-local error details for an error originating from the OS.
Definition error.c:56
Definition infix_internals.h:130
void * handle
Definition loader.c:50
The central structure for describing any data type in the FFI system.
Definition infix.h:161
size_t size
The total size of the type in bytes, per sizeof.
Definition infix.h:163