Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
os_api.h
Go to the documentation of this file.
1
13#ifndef FLECS_OS_API_H
14#define FLECS_OS_API_H
15
24#include <stdarg.h>
25#include <errno.h>
26#include <stdio.h>
27
28#if defined(ECS_TARGET_WINDOWS)
29#include <malloc.h>
30#elif defined(ECS_TARGET_FREEBSD)
31#include <stdlib.h>
32#else
33#include <alloca.h>
34#endif
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
41typedef struct ecs_time_t {
42 uint32_t sec;
43 uint32_t nanosec;
45
46/* Allocation counters */
47extern int64_t ecs_os_api_malloc_count;
48extern int64_t ecs_os_api_realloc_count;
49extern int64_t ecs_os_api_calloc_count;
50extern int64_t ecs_os_api_free_count;
52/* Use handle types that _at least_ can store pointers */
53typedef uintptr_t ecs_os_thread_t;
54typedef uintptr_t ecs_os_cond_t;
55typedef uintptr_t ecs_os_mutex_t;
56typedef uintptr_t ecs_os_dl_t;
57typedef uintptr_t ecs_os_sock_t;
60typedef uint64_t ecs_os_thread_id_t;
61
63typedef void (*ecs_os_proc_t)(void);
64
66typedef
67void (*ecs_os_api_init_t)(void);
68
70typedef
71void (*ecs_os_api_fini_t)(void);
72
74typedef
75void* (*ecs_os_api_malloc_t)(
76 ecs_size_t size);
77
79typedef
81 void *ptr);
82
84typedef
85void* (*ecs_os_api_realloc_t)(
86 void *ptr,
87 ecs_size_t size);
88
90typedef
91void* (*ecs_os_api_calloc_t)(
92 ecs_size_t size);
93
95typedef
96char* (*ecs_os_api_strdup_t)(
97 const char *str);
98
100typedef
101void* (*ecs_os_thread_callback_t)(
102 void*);
103
105typedef
108 void *param);
109
111typedef
112void* (*ecs_os_api_thread_join_t)(
113 ecs_os_thread_t thread);
114
116typedef
118
120typedef
123 void *param);
124
126typedef
127void* (*ecs_os_api_task_join_t)(
128 ecs_os_thread_t thread);
129
130/* Atomic increment / decrement */
132typedef
134 int32_t *value);
135
137typedef
139 int64_t *value);
140
141/* Mutex */
143typedef
145 void);
146
148typedef
150 ecs_os_mutex_t mutex);
151
153typedef
155 ecs_os_mutex_t mutex);
156
158typedef
160 ecs_os_mutex_t mutex);
161
162/* Condition variable */
164typedef
166 void);
167
169typedef
171 ecs_os_cond_t cond);
172
174typedef
176 ecs_os_cond_t cond);
177
179typedef
181 ecs_os_cond_t cond);
182
184typedef
186 ecs_os_cond_t cond,
187 ecs_os_mutex_t mutex);
188
190typedef
192 int32_t sec,
193 int32_t nanosec);
194
196typedef
198 bool enable);
199
201typedef
203 ecs_time_t *time_out);
204
206typedef
207uint64_t (*ecs_os_api_now_t)(void);
208
210typedef
212 int32_t level, /* Logging level */
213 const char *file, /* File where message was logged */
214 int32_t line, /* Line it was logged */
215 const char *msg);
216
218typedef
220 void);
221
223typedef
225 const char *libname);
226
228typedef
230 ecs_os_dl_t lib,
231 const char *procname);
232
234typedef
236 ecs_os_dl_t lib);
237
239typedef
240char* (*ecs_os_api_module_to_path_t)(
241 const char *module_id);
242
243/* Performance tracing */
244typedef void (*ecs_os_api_perf_trace_t)(
245 const char *filename,
246 size_t line,
247 const char *name);
248
249/* Prefix members of struct with 'ecs_' as some system headers may define
250 * macros for functions like "strdup", "log" or "_free" */
251
253typedef struct ecs_os_api_t {
254 /* API init / deinit */
258 /* Memory management */
264 /* Strings */
267 /* Threads */
272 /* Tasks */
276 /* Atomic increment / decrement */
282 /* Mutex */
288 /* Condition variable */
295 /* Time */
300 /* Logging */
309 /* Application termination */
312 /* Dynamic library loading */
317 /* Overridable function that translates from a logical module id to a
318 * shared library filename */
321 /* Overridable function that translates from a logical module id to a
322 * path that contains module-specif resources or assets */
325 /* Performance tracing */
326 ecs_os_api_perf_trace_t perf_trace_push_;
327
328 /* Performance tracing */
329 ecs_os_api_perf_trace_t perf_trace_pop_;
330
331 int32_t log_level_;
332 int32_t log_indent_;
336 ecs_flags32_t flags_;
338 FILE *log_out_;
341
343FLECS_API
345
357FLECS_API
358void ecs_os_init(void);
359
363FLECS_API
364void ecs_os_fini(void);
365
372FLECS_API
374 ecs_os_api_t *os_api);
375
381FLECS_API
383
390FLECS_API
392
397/* Memory management */
398#ifndef ecs_os_malloc
399#define ecs_os_malloc(size) ecs_os_api.malloc_(size)
400#endif
401#ifndef ecs_os_free
402#define ecs_os_free(ptr) ecs_os_api.free_(ptr)
403#endif
404#ifndef ecs_os_realloc
405#define ecs_os_realloc(ptr, size) ecs_os_api.realloc_(ptr, size)
406#endif
407#ifndef ecs_os_calloc
408#define ecs_os_calloc(size) ecs_os_api.calloc_(size)
409#endif
410#if defined(ECS_TARGET_WINDOWS)
411#define ecs_os_alloca(size) _alloca((size_t)(size))
412#else
413#define ecs_os_alloca(size) alloca((size_t)(size))
414#endif
415
416#define ecs_os_malloc_t(T) ECS_CAST(T*, ecs_os_malloc(ECS_SIZEOF(T)))
417#define ecs_os_malloc_n(T, count) ECS_CAST(T*, ecs_os_malloc(ECS_SIZEOF(T) * (count)))
418#define ecs_os_calloc_t(T) ECS_CAST(T*, ecs_os_calloc(ECS_SIZEOF(T)))
419#define ecs_os_calloc_n(T, count) ECS_CAST(T*, ecs_os_calloc(ECS_SIZEOF(T) * (count)))
420
421#define ecs_os_realloc_t(ptr, T) ECS_CAST(T*, ecs_os_realloc(ptr, ECS_SIZEOF(T)))
422#define ecs_os_realloc_n(ptr, T, count) ECS_CAST(T*, ecs_os_realloc(ptr, ECS_SIZEOF(T) * (count)))
423#define ecs_os_alloca_t(T) ECS_CAST(T*, ecs_os_alloca(ECS_SIZEOF(T)))
424#define ecs_os_alloca_n(T, count) ECS_CAST(T*, ecs_os_alloca(ECS_SIZEOF(T) * (count)))
425
426/* Strings */
427#ifndef ecs_os_strdup
428#define ecs_os_strdup(str) ecs_os_api.strdup_(str)
429#endif
430
431#ifdef __cplusplus
432#define ecs_os_strlen(str) static_cast<ecs_size_t>(strlen(str))
433#define ecs_os_strncmp(str1, str2, num) strncmp(str1, str2, static_cast<size_t>(num))
434#define ecs_os_memcmp(ptr1, ptr2, num) memcmp(ptr1, ptr2, static_cast<size_t>(num))
435#define ecs_os_memcpy(ptr1, ptr2, num) memcpy(ptr1, ptr2, static_cast<size_t>(num))
436#define ecs_os_memset(ptr, value, num) memset(ptr, value, static_cast<size_t>(num))
437#define ecs_os_memmove(dst, src, size) memmove(dst, src, static_cast<size_t>(size))
438#else
439#define ecs_os_strlen(str) (ecs_size_t)strlen(str)
440#define ecs_os_strncmp(str1, str2, num) strncmp(str1, str2, (size_t)(num))
441#define ecs_os_memcmp(ptr1, ptr2, num) memcmp(ptr1, ptr2, (size_t)(num))
442#define ecs_os_memcpy(ptr1, ptr2, num) memcpy(ptr1, ptr2, (size_t)(num))
443#define ecs_os_memset(ptr, value, num) memset(ptr, value, (size_t)(num))
444#define ecs_os_memmove(dst, src, size) memmove(dst, src, (size_t)(size))
445#endif
446
447#define ecs_os_memcpy_t(ptr1, ptr2, T) ecs_os_memcpy(ptr1, ptr2, ECS_SIZEOF(T))
448#define ecs_os_memcpy_n(ptr1, ptr2, T, count) ecs_os_memcpy(ptr1, ptr2, ECS_SIZEOF(T) * (size_t)count)
449#define ecs_os_memcmp_t(ptr1, ptr2, T) ecs_os_memcmp(ptr1, ptr2, ECS_SIZEOF(T))
450
451#define ecs_os_memmove_t(ptr1, ptr2, T) ecs_os_memmove(ptr1, ptr2, ECS_SIZEOF(T))
452#define ecs_os_memmove_n(ptr1, ptr2, T, count) ecs_os_memmove(ptr1, ptr2, ECS_SIZEOF(T) * (size_t)count)
453#define ecs_os_memmove_t(ptr1, ptr2, T) ecs_os_memmove(ptr1, ptr2, ECS_SIZEOF(T))
454
455#define ecs_os_strcmp(str1, str2) strcmp(str1, str2)
456#define ecs_os_memset_t(ptr, value, T) ecs_os_memset(ptr, value, ECS_SIZEOF(T))
457#define ecs_os_memset_n(ptr, value, T, count) ecs_os_memset(ptr, value, ECS_SIZEOF(T) * (size_t)count)
458#define ecs_os_zeromem(ptr) ecs_os_memset(ptr, 0, ECS_SIZEOF(*ptr))
459
460#define ecs_os_memdup_t(ptr, T) ecs_os_memdup(ptr, ECS_SIZEOF(T))
461#define ecs_os_memdup_n(ptr, T, count) ecs_os_memdup(ptr, ECS_SIZEOF(T) * count)
462
463#define ecs_offset(ptr, T, index)\
464 ECS_CAST(T*, ECS_OFFSET(ptr, ECS_SIZEOF(T) * index))
465
466#if !defined(ECS_TARGET_POSIX) && !defined(ECS_TARGET_MINGW)
467#define ecs_os_strcat(str1, str2) strcat_s(str1, INT_MAX, str2)
468#define ecs_os_snprintf(ptr, len, ...) sprintf_s(ptr, ECS_CAST(size_t, len), __VA_ARGS__)
469#define ecs_os_vsnprintf(ptr, len, fmt, args) vsnprintf(ptr, ECS_CAST(size_t, len), fmt, args)
470#define ecs_os_strcpy(str1, str2) strcpy_s(str1, INT_MAX, str2)
471#define ecs_os_strncpy(str1, str2, len) strncpy_s(str1, INT_MAX, str2, ECS_CAST(size_t, len))
472#else
473#define ecs_os_strcat(str1, str2) strcat(str1, str2)
474#define ecs_os_snprintf(ptr, len, ...) snprintf(ptr, ECS_CAST(size_t, len), __VA_ARGS__)
475#define ecs_os_vsnprintf(ptr, len, fmt, args) vsnprintf(ptr, ECS_CAST(size_t, len), fmt, args)
476#define ecs_os_strcpy(str1, str2) strcpy(str1, str2)
477#define ecs_os_strncpy(str1, str2, len) strncpy(str1, str2, ECS_CAST(size_t, len))
478#endif
479
480/* Files */
481#ifndef ECS_TARGET_POSIX
482#define ecs_os_fopen(result, file, mode) fopen_s(result, file, mode)
483#else
484#define ecs_os_fopen(result, file, mode) (*(result)) = fopen(file, mode)
485#endif
486
487/* Threads */
488#define ecs_os_thread_new(callback, param) ecs_os_api.thread_new_(callback, param)
489#define ecs_os_thread_join(thread) ecs_os_api.thread_join_(thread)
490#define ecs_os_thread_self() ecs_os_api.thread_self_()
491
492/* Tasks */
493#define ecs_os_task_new(callback, param) ecs_os_api.task_new_(callback, param)
494#define ecs_os_task_join(thread) ecs_os_api.task_join_(thread)
495
496/* Atomic increment / decrement */
497#define ecs_os_ainc(value) ecs_os_api.ainc_(value)
498#define ecs_os_adec(value) ecs_os_api.adec_(value)
499#define ecs_os_lainc(value) ecs_os_api.lainc_(value)
500#define ecs_os_ladec(value) ecs_os_api.ladec_(value)
501
502/* Mutex */
503#define ecs_os_mutex_new() ecs_os_api.mutex_new_()
504#define ecs_os_mutex_free(mutex) ecs_os_api.mutex_free_(mutex)
505#define ecs_os_mutex_lock(mutex) ecs_os_api.mutex_lock_(mutex)
506#define ecs_os_mutex_unlock(mutex) ecs_os_api.mutex_unlock_(mutex)
507
508/* Condition variable */
509#define ecs_os_cond_new() ecs_os_api.cond_new_()
510#define ecs_os_cond_free(cond) ecs_os_api.cond_free_(cond)
511#define ecs_os_cond_signal(cond) ecs_os_api.cond_signal_(cond)
512#define ecs_os_cond_broadcast(cond) ecs_os_api.cond_broadcast_(cond)
513#define ecs_os_cond_wait(cond, mutex) ecs_os_api.cond_wait_(cond, mutex)
514
515/* Time */
516#define ecs_os_sleep(sec, nanosec) ecs_os_api.sleep_(sec, nanosec)
517#define ecs_os_now() ecs_os_api.now_()
518#define ecs_os_get_time(time_out) ecs_os_api.get_time_(time_out)
519
520#ifndef FLECS_DISABLE_COUNTERS
521#ifdef FLECS_ACCURATE_COUNTERS
522#define ecs_os_inc(v) (ecs_os_ainc(v))
523#define ecs_os_linc(v) (ecs_os_lainc(v))
524#define ecs_os_dec(v) (ecs_os_adec(v))
525#define ecs_os_ldec(v) (ecs_os_ladec(v))
526#else
527#define ecs_os_inc(v) (++(*v))
528#define ecs_os_linc(v) (++(*v))
529#define ecs_os_dec(v) (--(*v))
530#define ecs_os_ldec(v) (--(*v))
531#endif
532#else
533#define ecs_os_inc(v)
534#define ecs_os_linc(v)
535#define ecs_os_dec(v)
536#define ecs_os_ldec(v)
537#endif
538
539
540#ifdef ECS_TARGET_MINGW
541/* mingw bug: without this a conversion error is thrown, but isnan/isinf should
542 * accept float, double and long double. */
543#define ecs_os_isnan(val) (isnan((float)val))
544#define ecs_os_isinf(val) (isinf((float)val))
545#else
546#define ecs_os_isnan(val) (isnan(val))
547#define ecs_os_isinf(val) (isinf(val))
548#endif
549
550/* Application termination */
551#define ecs_os_abort() ecs_os_api.abort_()
552
553/* Dynamic libraries */
554#define ecs_os_dlopen(libname) ecs_os_api.dlopen_(libname)
555#define ecs_os_dlproc(lib, procname) ecs_os_api.dlproc_(lib, procname)
556#define ecs_os_dlclose(lib) ecs_os_api.dlclose_(lib)
557
558/* Module id translation */
559#define ecs_os_module_to_dl(lib) ecs_os_api.module_to_dl_(lib)
560#define ecs_os_module_to_etc(lib) ecs_os_api.module_to_etc_(lib)
561
567/* Logging */
568
575FLECS_API
577 const char *file,
578 int32_t line,
579 const char *msg);
580
587FLECS_API
589 const char *file,
590 int32_t line,
591 const char *msg);
592
599FLECS_API
601 const char *file,
602 int32_t line,
603 const char *msg);
604
611FLECS_API
613 const char *file,
614 int32_t line,
615 const char *msg);
616
623FLECS_API
625 const char *file,
626 int32_t line,
627 const char *msg);
628
634FLECS_API
635const char* ecs_os_strerror(
636 int err);
637
644FLECS_API
646 char **str,
647 const char *value);
648
649/* Profile tracing */
650#ifdef FLECS_PERF_TRACE
651#define ecs_os_perf_trace_push(name) ecs_os_perf_trace_push_(__FILE__, __LINE__, name)
652#define ecs_os_perf_trace_pop(name) ecs_os_perf_trace_pop_(__FILE__, __LINE__, name)
653#else
654#define ecs_os_perf_trace_push(name)
655#define ecs_os_perf_trace_pop(name)
656#endif
657
658void ecs_os_perf_trace_push_(
659 const char *file,
660 size_t line,
661 const char *name);
662
663void ecs_os_perf_trace_pop_(
664 const char *file,
665 size_t line,
666 const char *name);
667
672FLECS_API
674 double t);
675
691FLECS_API
693 ecs_time_t *start);
694
701FLECS_API
703 ecs_time_t t1,
704 ecs_time_t t2);
705
711FLECS_API
713 ecs_time_t t);
714
721FLECS_API
723 const void *src,
724 ecs_size_t size);
725
727FLECS_API
729
731FLECS_API
733
735FLECS_API
737
739FLECS_API
741
743FLECS_API
745
747FLECS_API
748bool ecs_os_has_dl(void);
749
751FLECS_API
753
754#ifdef __cplusplus
755}
756#endif
757
760#endif
ecs_os_thread_t(* ecs_os_api_task_new_t)(ecs_os_thread_callback_t callback, void *param)
OS API task_new function type.
Definition os_api.h:121
void *(* ecs_os_api_calloc_t)(ecs_size_t size)
OS API calloc function type.
Definition os_api.h:91
void(* ecs_os_api_cond_signal_t)(ecs_os_cond_t cond)
OS API cond_signal function type.
Definition os_api.h:175
FLECS_API void ecs_os_err(const char *file, int32_t line, const char *msg)
Log at error level.
void(* ecs_os_api_cond_free_t)(ecs_os_cond_t cond)
OS API cond_free function type.
Definition os_api.h:170
void *(* ecs_os_api_thread_join_t)(ecs_os_thread_t thread)
OS API thread_join function type.
Definition os_api.h:112
ecs_os_dl_t(* ecs_os_api_dlopen_t)(const char *libname)
OS API dlopen function type.
Definition os_api.h:224
uintptr_t ecs_os_dl_t
OS dynamic library.
Definition os_api.h:56
uint64_t ecs_os_thread_id_t
64 bit thread id.
Definition os_api.h:60
FLECS_API ecs_os_api_t ecs_os_api
Static OS API variable with configured callbacks.
void(* ecs_os_api_get_time_t)(ecs_time_t *time_out)
OS API get_time function type.
Definition os_api.h:202
int64_t ecs_os_api_realloc_count
realloc count.
int64_t ecs_os_api_free_count
free count.
ecs_os_thread_t(* ecs_os_api_thread_new_t)(ecs_os_thread_callback_t callback, void *param)
OS API thread_new function type.
Definition os_api.h:106
void *(* ecs_os_thread_callback_t)(void *)
OS API thread_callback function type.
Definition os_api.h:101
FLECS_API double ecs_time_measure(ecs_time_t *start)
Measure time since provided timestamp.
FLECS_API bool ecs_os_has_time(void)
Are time functions available?
FLECS_API bool ecs_os_has_dl(void)
Are dynamic library functions available?
ecs_os_thread_id_t(* ecs_os_api_thread_self_t)(void)
OS API thread_self function type.
Definition os_api.h:117
FLECS_API bool ecs_os_has_logging(void)
Are logging functions available?
FLECS_API bool ecs_os_has_modules(void)
Are module path functions available?
uintptr_t ecs_os_thread_t
OS thread.
Definition os_api.h:53
void(* ecs_os_api_mutex_free_t)(ecs_os_mutex_t mutex)
OS API mutex_free function type.
Definition os_api.h:159
uintptr_t ecs_os_sock_t
OS socket.
Definition os_api.h:57
FLECS_API void ecs_os_set_api(ecs_os_api_t *os_api)
Override OS API.
char *(* ecs_os_api_module_to_path_t)(const char *module_id)
OS API module_to_path function type.
Definition os_api.h:240
void(* ecs_os_api_mutex_lock_t)(ecs_os_mutex_t mutex)
OS API mutex_lock function type.
Definition os_api.h:149
void(* ecs_os_api_init_t)(void)
OS API init.
Definition os_api.h:67
FLECS_API void ecs_os_warn(const char *file, int32_t line, const char *msg)
Log at warning level.
FLECS_API void ecs_os_trace(const char *file, int32_t line, const char *msg)
Log at trace level.
ecs_os_proc_t(* ecs_os_api_dlproc_t)(ecs_os_dl_t lib, const char *procname)
OS API dlproc function type.
Definition os_api.h:229
FLECS_API bool ecs_os_has_task_support(void)
Are task functions available?
FLECS_API ecs_os_api_t ecs_os_get_api(void)
Get OS API.
void(* ecs_os_api_dlclose_t)(ecs_os_dl_t lib)
OS API dlclose function type.
Definition os_api.h:235
ecs_os_mutex_t(* ecs_os_api_mutex_new_t)(void)
OS API mutex_new function type.
Definition os_api.h:144
void(* ecs_os_api_enable_high_timer_resolution_t)(bool enable)
OS API enable_high_timer_resolution function type.
Definition os_api.h:197
FLECS_API double ecs_time_to_double(ecs_time_t t)
Convert time value to a double.
uint64_t(* ecs_os_api_now_t)(void)
OS API now function type.
Definition os_api.h:207
ecs_os_cond_t(* ecs_os_api_cond_new_t)(void)
OS API cond_new function type.
Definition os_api.h:165
void(* ecs_os_api_cond_broadcast_t)(ecs_os_cond_t cond)
OS API cond_broadcast function type.
Definition os_api.h:180
void *(* ecs_os_api_realloc_t)(void *ptr, ecs_size_t size)
OS API realloc function type.
Definition os_api.h:85
FLECS_API void ecs_os_strset(char **str, const char *value)
Utility for assigning strings.
int32_t(* ecs_os_api_ainc_t)(int32_t *value)
OS API ainc function type.
Definition os_api.h:133
FLECS_API void ecs_os_dbg(const char *file, int32_t line, const char *msg)
Macro utilities.
void(* ecs_os_proc_t)(void)
Generic function pointer type.
Definition os_api.h:63
char *(* ecs_os_api_strdup_t)(const char *str)
OS API strdup function type.
Definition os_api.h:96
uintptr_t ecs_os_mutex_t
OS mutex.
Definition os_api.h:55
FLECS_API ecs_time_t ecs_time_sub(ecs_time_t t1, ecs_time_t t2)
Calculate difference between two timestamps.
void(* ecs_os_api_mutex_unlock_t)(ecs_os_mutex_t mutex)
OS API mutex_unlock function type.
Definition os_api.h:154
void(* ecs_os_api_fini_t)(void)
OS API deinit.
Definition os_api.h:71
void(* ecs_os_api_sleep_t)(int32_t sec, int32_t nanosec)
OS API sleep function type.
Definition os_api.h:191
uintptr_t ecs_os_cond_t
OS cond.
Definition os_api.h:54
void(* ecs_os_api_free_t)(void *ptr)
OS API free function type.
Definition os_api.h:80
struct ecs_time_t ecs_time_t
Time type.
int64_t ecs_os_api_malloc_count
malloc count.
FLECS_API bool ecs_os_has_threading(void)
Are threading functions available?
FLECS_API void * ecs_os_memdup(const void *src, ecs_size_t size)
Return newly allocated memory that contains a copy of src.
void(* ecs_os_api_cond_wait_t)(ecs_os_cond_t cond, ecs_os_mutex_t mutex)
OS API cond_wait function type.
Definition os_api.h:185
struct ecs_os_api_t ecs_os_api_t
OS API interface.
FLECS_API void ecs_os_set_api_defaults(void)
Set default values for OS API.
FLECS_API void ecs_os_fatal(const char *file, int32_t line, const char *msg)
Log at fatal level.
void(* ecs_os_api_abort_t)(void)
OS API abort function type.
Definition os_api.h:219
int64_t(* ecs_os_api_lainc_t)(int64_t *value)
OS API lainc function type.
Definition os_api.h:138
FLECS_API void ecs_os_init(void)
Initialize OS API.
FLECS_API bool ecs_os_has_heap(void)
Are heap functions available?
void(* ecs_os_api_log_t)(int32_t level, const char *file, int32_t line, const char *msg)
OS API log function type.
Definition os_api.h:211
int64_t ecs_os_api_calloc_count
calloc count.
FLECS_API void ecs_os_fini(void)
Deinitialize OS API.
FLECS_API const char * ecs_os_strerror(int err)
Convert errno to string.
FLECS_API void ecs_sleepf(double t)
Sleep with floating point time.
void *(* ecs_os_api_malloc_t)(ecs_size_t size)
OS API malloc function type.
Definition os_api.h:75
OS API interface.
Definition os_api.h:253
ecs_os_api_cond_wait_t cond_wait_
cond_wait callback.
Definition os_api.h:293
ecs_os_api_thread_new_t thread_new_
thread_new callback.
Definition os_api.h:268
ecs_os_api_free_t free_
free callback.
Definition os_api.h:262
int32_t log_last_error_
Last logged error code.
Definition os_api.h:333
ecs_os_api_sleep_t sleep_
sleep callback.
Definition os_api.h:296
ecs_os_api_realloc_t realloc_
realloc callback.
Definition os_api.h:260
ecs_os_api_mutex_lock_t mutex_unlock_
mutex_unlock callback.
Definition os_api.h:286
ecs_os_api_abort_t abort_
abort callback.
Definition os_api.h:310
ecs_os_api_lainc_t lainc_
lainc callback.
Definition os_api.h:279
ecs_os_api_init_t init_
init callback.
Definition os_api.h:255
ecs_os_api_get_time_t get_time_
get_time callback.
Definition os_api.h:298
ecs_os_api_cond_broadcast_t cond_broadcast_
cond_broadcast callback.
Definition os_api.h:292
ecs_os_api_calloc_t calloc_
calloc callback.
Definition os_api.h:261
ecs_os_api_dlopen_t dlopen_
dlopen callback.
Definition os_api.h:313
ecs_os_api_thread_self_t thread_self_
thread_self callback.
Definition os_api.h:270
ecs_os_api_thread_join_t thread_join_
thread_join callback.
Definition os_api.h:269
ecs_os_api_module_to_path_t module_to_dl_
module_to_dl callback.
Definition os_api.h:319
int32_t log_indent_
Tracing indentation level.
Definition os_api.h:332
ecs_os_api_malloc_t malloc_
malloc callback.
Definition os_api.h:259
ecs_os_api_log_t log_
log callback.
Definition os_api.h:301
ecs_os_api_thread_join_t task_join_
task_join callback.
Definition os_api.h:274
int64_t log_last_timestamp_
Last logged timestamp.
Definition os_api.h:334
ecs_os_api_mutex_new_t mutex_new_
mutex_new callback.
Definition os_api.h:283
ecs_os_api_lainc_t ladec_
ladec callback.
Definition os_api.h:280
ecs_os_api_cond_new_t cond_new_
cond_new callback.
Definition os_api.h:289
ecs_os_api_thread_new_t task_new_
task_new callback.
Definition os_api.h:273
FILE * log_out_
File used for logging output (hint, log_ decides where to write)
Definition os_api.h:338
int32_t log_level_
Tracing level.
Definition os_api.h:331
ecs_os_api_fini_t fini_
fini callback.
Definition os_api.h:256
ecs_os_api_cond_signal_t cond_signal_
cond_signal callback.
Definition os_api.h:291
ecs_os_api_cond_free_t cond_free_
cond_free callback.
Definition os_api.h:290
ecs_os_api_strdup_t strdup_
strdup callback.
Definition os_api.h:265
ecs_os_api_mutex_free_t mutex_free_
mutex_free callback.
Definition os_api.h:284
ecs_os_api_module_to_path_t module_to_etc_
module_to_etc callback.
Definition os_api.h:323
ecs_flags32_t flags_
OS API flags.
Definition os_api.h:336
ecs_os_api_now_t now_
now callback.
Definition os_api.h:297
ecs_os_api_mutex_lock_t mutex_lock_
mutex_lock callback.
Definition os_api.h:285
ecs_os_api_ainc_t ainc_
ainc callback.
Definition os_api.h:277
ecs_os_api_ainc_t adec_
adec callback.
Definition os_api.h:278
ecs_os_api_dlproc_t dlproc_
dlproc callback.
Definition os_api.h:314
ecs_os_api_dlclose_t dlclose_
dlclose callback.
Definition os_api.h:315
Time type.
Definition os_api.h:41
uint32_t sec
Second part.
Definition os_api.h:42
uint32_t nanosec
Nanosecond part.
Definition os_api.h:43