Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
System

Functions

bj_bool bj_initialize (bj_error **p_error)
void bj_shutdown (bj_error **p_error)
void * bj_load_library (const char *p_path)
void bj_unload_library (void *p_handle)
void * bj_library_symbol (void *p_handle, const char *p_name)

Detailed Description

Abstraction to usual system calls such as library loading and time.

Function Documentation

◆ bj_initialize()

bj_bool bj_initialize ( bj_error ** p_error)

Initializes the system.

Parameters
p_errorAn optional location to an error object.

The initialization process will iteratively try to initialize a subsystem among the ones available and returns on the first that succeeded.

Returns
true if the system is properly initialized, BJ_FALSE otherswise.

◆ bj_library_symbol()

void * bj_library_symbol ( void * p_handle,
const char * p_name )

Get the address of a function exported by p_handle given its name.

This function is an abstraction over the platform specific function like dlsym and GetProcAddress.

Parameters
p_handleA library handle provided by bj_load_library.
p_nameC-String name of the function to retrieve
Returns
0 or the address of the retrieved function.
Behaviour
  • On Unix platforms, p_handle and p_name are passed to dlsym().
  • On Windows, p_handle and p_name are passed to GetProcAddress().
Memory Management

The caller is responsible for release the loaded function using bj_unload_library with p_handle.

See also
bj_load_library, bj_unload_library
dlsym(), GetProcAddress()

◆ bj_load_library()

void * bj_load_library ( const char * p_path)

Load the provided dynamic library and returns and opaque handle to it.

This function is an abstraction over the platform specific function like dlopen and LoadLibrary. The provided pointer can be used with bj_library_symbol to get a function from the loaded library.

Parameters
p_pathA C-string path to the library to load.
Returns
0 or a handle to the loaded library.
Behaviour
  • On Unix platforms, p_path is passed to dlopen() with RTLD_LAZY and RTLD_LOCAL flags.
  • On Windows, p_path is passed to LoadLibraryA().
Memory Management

The caller is responsible for release the loaded library using bj_unload_library.

See also
bj_library_symbol, bj_unload_library
dlopen(), LoadLibraryA()

◆ bj_shutdown()

void bj_shutdown ( bj_error ** p_error)

De-initializes the system.

Parameters
p_errorAn optional location to an error object.

◆ bj_unload_library()

void bj_unload_library ( void * p_handle)

Unload a library loaded with bj_load_library from memory.

This function is an abstraction over the platform specific function like dlclose and FreeLibrary.

Parameters
p_handleThe library to unload.
Behaviour
  • On Unix platforms, p_handle is passed to dlclose().
  • On Windows, p_path is passed to FreeLibrary().
Memory Management

The caller is responsible for release the loaded library using bj_unload_library.

See also
bj_library_symbol, bj_unload_library
dlclose(), FreeLibrary()