Flecs v4.0
A fast entity component system (ECS) for C & C++
|
Interface for providing OS specific functionality. More...
Classes | |
struct | ecs_time_t |
Time type. More... | |
struct | ecs_os_api_t |
OS API interface. More... | |
Macros | |
#define | ecs_os_perf_trace_push(name) |
#define | ecs_os_perf_trace_pop(name) |
Typedefs | |
typedef struct ecs_time_t | ecs_time_t |
Time type. | |
typedef uintptr_t | ecs_os_thread_t |
OS thread. | |
typedef uintptr_t | ecs_os_cond_t |
OS cond. | |
typedef uintptr_t | ecs_os_mutex_t |
OS mutex. | |
typedef uintptr_t | ecs_os_dl_t |
OS dynamic library. | |
typedef uintptr_t | ecs_os_sock_t |
OS socket. | |
typedef uint64_t | ecs_os_thread_id_t |
64 bit thread id. | |
typedef void(* | ecs_os_proc_t) (void) |
Generic function pointer type. | |
typedef void(* | ecs_os_api_init_t) (void) |
OS API init. | |
typedef void(* | ecs_os_api_fini_t) (void) |
OS API deinit. | |
typedef void *(* | ecs_os_api_malloc_t) (ecs_size_t size) |
OS API malloc function type. | |
typedef void(* | ecs_os_api_free_t) (void *ptr) |
OS API free function type. | |
typedef void *(* | ecs_os_api_realloc_t) (void *ptr, ecs_size_t size) |
OS API realloc function type. | |
typedef void *(* | ecs_os_api_calloc_t) (ecs_size_t size) |
OS API calloc function type. | |
typedef char *(* | ecs_os_api_strdup_t) (const char *str) |
OS API strdup function type. | |
typedef void *(* | ecs_os_thread_callback_t) (void *) |
OS API thread_callback function type. | |
typedef ecs_os_thread_t(* | ecs_os_api_thread_new_t) (ecs_os_thread_callback_t callback, void *param) |
OS API thread_new function type. | |
typedef void *(* | ecs_os_api_thread_join_t) (ecs_os_thread_t thread) |
OS API thread_join function type. | |
typedef ecs_os_thread_id_t(* | ecs_os_api_thread_self_t) (void) |
OS API thread_self function type. | |
typedef ecs_os_thread_t(* | ecs_os_api_task_new_t) (ecs_os_thread_callback_t callback, void *param) |
OS API task_new function type. | |
typedef void *(* | ecs_os_api_task_join_t) (ecs_os_thread_t thread) |
OS API task_join function type. | |
typedef int32_t(* | ecs_os_api_ainc_t) (int32_t *value) |
OS API ainc function type. | |
typedef int64_t(* | ecs_os_api_lainc_t) (int64_t *value) |
OS API lainc function type. | |
typedef ecs_os_mutex_t(* | ecs_os_api_mutex_new_t) (void) |
OS API mutex_new function type. | |
typedef void(* | ecs_os_api_mutex_lock_t) (ecs_os_mutex_t mutex) |
OS API mutex_lock function type. | |
typedef void(* | ecs_os_api_mutex_unlock_t) (ecs_os_mutex_t mutex) |
OS API mutex_unlock function type. | |
typedef void(* | ecs_os_api_mutex_free_t) (ecs_os_mutex_t mutex) |
OS API mutex_free function type. | |
typedef ecs_os_cond_t(* | ecs_os_api_cond_new_t) (void) |
OS API cond_new function type. | |
typedef void(* | ecs_os_api_cond_free_t) (ecs_os_cond_t cond) |
OS API cond_free function type. | |
typedef void(* | ecs_os_api_cond_signal_t) (ecs_os_cond_t cond) |
OS API cond_signal function type. | |
typedef void(* | ecs_os_api_cond_broadcast_t) (ecs_os_cond_t cond) |
OS API cond_broadcast function type. | |
typedef void(* | ecs_os_api_cond_wait_t) (ecs_os_cond_t cond, ecs_os_mutex_t mutex) |
OS API cond_wait function type. | |
typedef void(* | ecs_os_api_sleep_t) (int32_t sec, int32_t nanosec) |
OS API sleep function type. | |
typedef void(* | ecs_os_api_enable_high_timer_resolution_t) (bool enable) |
OS API enable_high_timer_resolution function type. | |
typedef void(* | ecs_os_api_get_time_t) (ecs_time_t *time_out) |
OS API get_time function type. | |
typedef uint64_t(* | ecs_os_api_now_t) (void) |
OS API now function type. | |
typedef void(* | ecs_os_api_log_t) (int32_t level, const char *file, int32_t line, const char *msg) |
OS API log function type. | |
typedef void(* | ecs_os_api_abort_t) (void) |
OS API abort function type. | |
typedef ecs_os_dl_t(* | ecs_os_api_dlopen_t) (const char *libname) |
OS API dlopen function type. | |
typedef ecs_os_proc_t(* | ecs_os_api_dlproc_t) (ecs_os_dl_t lib, const char *procname) |
OS API dlproc function type. | |
typedef void(* | ecs_os_api_dlclose_t) (ecs_os_dl_t lib) |
OS API dlclose function type. | |
typedef char *(* | ecs_os_api_module_to_path_t) (const char *module_id) |
OS API module_to_path function type. | |
typedef void(* | ecs_os_api_perf_trace_t) (const char *filename, size_t line, const char *name) |
typedef struct ecs_os_api_t | ecs_os_api_t |
OS API interface. | |
Functions | |
FLECS_API void | ecs_os_init (void) |
Initialize OS API. | |
FLECS_API void | ecs_os_fini (void) |
Deinitialize OS API. | |
FLECS_API void | ecs_os_set_api (ecs_os_api_t *os_api) |
Override OS API. | |
FLECS_API ecs_os_api_t | ecs_os_get_api (void) |
Get OS API. | |
FLECS_API void | ecs_os_set_api_defaults (void) |
Set default values for OS API. | |
FLECS_API void | ecs_os_dbg (const char *file, int32_t line, const char *msg) |
Macro utilities. | |
FLECS_API void | ecs_os_trace (const char *file, int32_t line, const char *msg) |
Log at trace level. | |
FLECS_API void | ecs_os_warn (const char *file, int32_t line, const char *msg) |
Log at warning level. | |
FLECS_API void | ecs_os_err (const char *file, int32_t line, const char *msg) |
Log at error level. | |
FLECS_API void | ecs_os_fatal (const char *file, int32_t line, const char *msg) |
Log at fatal level. | |
FLECS_API const char * | ecs_os_strerror (int err) |
Convert errno to string. | |
FLECS_API void | ecs_os_strset (char **str, const char *value) |
Utility for assigning strings. | |
void | ecs_os_perf_trace_push_ (const char *file, size_t line, const char *name) |
void | ecs_os_perf_trace_pop_ (const char *file, size_t line, const char *name) |
FLECS_API void | ecs_sleepf (double t) |
Sleep with floating point time. | |
FLECS_API double | ecs_time_measure (ecs_time_t *start) |
Measure time since provided timestamp. | |
FLECS_API ecs_time_t | ecs_time_sub (ecs_time_t t1, ecs_time_t t2) |
Calculate difference between two timestamps. | |
FLECS_API double | ecs_time_to_double (ecs_time_t t) |
Convert time value to a double. | |
FLECS_API void * | ecs_os_memdup (const void *src, ecs_size_t size) |
Return newly allocated memory that contains a copy of src. | |
FLECS_API bool | ecs_os_has_heap (void) |
Are heap functions available? | |
FLECS_API bool | ecs_os_has_threading (void) |
Are threading functions available? | |
FLECS_API bool | ecs_os_has_task_support (void) |
Are task functions available? | |
FLECS_API bool | ecs_os_has_time (void) |
Are time functions available? | |
FLECS_API bool | ecs_os_has_logging (void) |
Are logging functions available? | |
FLECS_API bool | ecs_os_has_dl (void) |
Are dynamic library functions available? | |
FLECS_API bool | ecs_os_has_modules (void) |
Are module path functions available? | |
Variables | |
int64_t | ecs_os_api_malloc_count |
malloc count. | |
int64_t | ecs_os_api_realloc_count |
realloc count. | |
int64_t | ecs_os_api_calloc_count |
calloc count. | |
int64_t | ecs_os_api_free_count |
free count. | |
FLECS_API ecs_os_api_t | ecs_os_api |
Static OS API variable with configured callbacks. | |
Interface for providing OS specific functionality.
typedef void(* ecs_os_api_abort_t) (void) |
typedef int32_t(* ecs_os_api_ainc_t) (int32_t *value) |
typedef void *(* ecs_os_api_calloc_t) (ecs_size_t size) |
typedef void(* ecs_os_api_cond_broadcast_t) (ecs_os_cond_t cond) |
typedef void(* ecs_os_api_cond_free_t) (ecs_os_cond_t cond) |
typedef ecs_os_cond_t(* ecs_os_api_cond_new_t) (void) |
typedef void(* ecs_os_api_cond_signal_t) (ecs_os_cond_t cond) |
typedef void(* ecs_os_api_cond_wait_t) (ecs_os_cond_t cond, ecs_os_mutex_t mutex) |
typedef void(* ecs_os_api_dlclose_t) (ecs_os_dl_t lib) |
typedef ecs_os_dl_t(* ecs_os_api_dlopen_t) (const char *libname) |
typedef ecs_os_proc_t(* ecs_os_api_dlproc_t) (ecs_os_dl_t lib, const char *procname) |
typedef void(* ecs_os_api_enable_high_timer_resolution_t) (bool enable) |
typedef void(* ecs_os_api_free_t) (void *ptr) |
typedef void(* ecs_os_api_get_time_t) (ecs_time_t *time_out) |
typedef int64_t(* ecs_os_api_lainc_t) (int64_t *value) |
typedef void(* ecs_os_api_log_t) (int32_t level, const char *file, int32_t line, const char *msg) |
typedef void *(* ecs_os_api_malloc_t) (ecs_size_t size) |
typedef char *(* ecs_os_api_module_to_path_t) (const char *module_id) |
typedef void(* ecs_os_api_mutex_free_t) (ecs_os_mutex_t mutex) |
typedef void(* ecs_os_api_mutex_lock_t) (ecs_os_mutex_t mutex) |
typedef ecs_os_mutex_t(* ecs_os_api_mutex_new_t) (void) |
typedef void(* ecs_os_api_mutex_unlock_t) (ecs_os_mutex_t mutex) |
typedef uint64_t(* ecs_os_api_now_t) (void) |
typedef void(* ecs_os_api_perf_trace_t) (const char *filename, size_t line, const char *name) |
typedef void *(* ecs_os_api_realloc_t) (void *ptr, ecs_size_t size) |
typedef void(* ecs_os_api_sleep_t) (int32_t sec, int32_t nanosec) |
typedef char *(* ecs_os_api_strdup_t) (const char *str) |
typedef void *(* ecs_os_api_task_join_t) (ecs_os_thread_t thread) |
typedef ecs_os_thread_t(* ecs_os_api_task_new_t) (ecs_os_thread_callback_t callback, void *param) |
typedef void *(* ecs_os_api_thread_join_t) (ecs_os_thread_t thread) |
typedef ecs_os_thread_t(* ecs_os_api_thread_new_t) (ecs_os_thread_callback_t callback, void *param) |
typedef ecs_os_thread_id_t(* ecs_os_api_thread_self_t) (void) |
typedef uintptr_t ecs_os_cond_t |
typedef uintptr_t ecs_os_dl_t |
typedef uintptr_t ecs_os_mutex_t |
typedef void(* ecs_os_proc_t) (void) |
typedef uintptr_t ecs_os_sock_t |
typedef void *(* ecs_os_thread_callback_t) (void *) |
typedef uint64_t ecs_os_thread_id_t |
typedef uintptr_t ecs_os_thread_t |
FLECS_API void ecs_os_dbg | ( | const char * | file, |
int32_t | line, | ||
const char * | msg ) |
Macro utilities.
Log at debug level.
file | The file to log. |
line | The line to log. |
msg | The message to log. |
FLECS_API void ecs_os_err | ( | const char * | file, |
int32_t | line, | ||
const char * | msg ) |
Log at error level.
file | The file to log. |
line | The line to log. |
msg | The message to log. |
FLECS_API void ecs_os_fatal | ( | const char * | file, |
int32_t | line, | ||
const char * | msg ) |
Log at fatal level.
file | The file to log. |
line | The line to log. |
msg | The message to log. |
FLECS_API void ecs_os_fini | ( | void | ) |
Deinitialize OS API.
This operation is not usually called by an application.
FLECS_API ecs_os_api_t ecs_os_get_api | ( | void | ) |
FLECS_API void ecs_os_init | ( | void | ) |
Initialize OS API.
This operation is not usually called by an application. To override callbacks of the OS API, use the following pattern:
FLECS_API void * ecs_os_memdup | ( | const void * | src, |
ecs_size_t | size ) |
Return newly allocated memory that contains a copy of src.
src | The source pointer. |
size | The number of bytes to copy. |
FLECS_API void ecs_os_set_api | ( | ecs_os_api_t * | os_api | ) |
Override OS API.
This overrides the OS API struct with new values for callbacks. See ecs_os_init() on how to use the function.
os_api | Pointer to struct with values to set. |
FLECS_API void ecs_os_set_api_defaults | ( | void | ) |
Set default values for OS API.
This initializes the OS API struct with default values for callbacks like malloc and free.
FLECS_API const char * ecs_os_strerror | ( | int | err | ) |
Convert errno to string.
err | The error number. |
FLECS_API void ecs_os_strset | ( | char ** | str, |
const char * | value ) |
Utility for assigning strings.
This operation frees an existing string and duplicates the input string.
str | Pointer to a string value. |
value | The string value to assign. |
FLECS_API void ecs_os_trace | ( | const char * | file, |
int32_t | line, | ||
const char * | msg ) |
Log at trace level.
file | The file to log. |
line | The line to log. |
msg | The message to log. |
FLECS_API void ecs_os_warn | ( | const char * | file, |
int32_t | line, | ||
const char * | msg ) |
Log at warning level.
file | The file to log. |
line | The line to log. |
msg | The message to log. |
FLECS_API void ecs_sleepf | ( | double | t | ) |
Sleep with floating point time.
t | The time in seconds. |
FLECS_API double ecs_time_measure | ( | ecs_time_t * | start | ) |
Measure time since provided timestamp.
Use with a time value initialized to 0 to obtain the number of seconds since the epoch. The operation will write the current timestamp in start.
Usage:
start | The starting timestamp. |
FLECS_API ecs_time_t ecs_time_sub | ( | ecs_time_t | t1, |
ecs_time_t | t2 ) |
Calculate difference between two timestamps.
t1 | The first timestamp. |
t2 | The first timestamp. |
FLECS_API double ecs_time_to_double | ( | ecs_time_t | t | ) |
Convert time value to a double.
t | The timestamp. |