14 #define GOLIOTH_SYS_WAIT_FOREVER -1
77 #ifndef golioth_sys_malloc
78 #define golioth_sys_malloc(sz) malloc((sz))
81 #ifndef golioth_sys_free
82 #define golioth_sys_free(ptr) free((ptr))
89 #if CONFIG_GOLIOTH_DEBUG_LOG_ENABLE
94 #define LOG_COLOR_RED "31"
95 #define LOG_COLOR_GREEN "32"
96 #define LOG_COLOR_BROWN "33"
97 #define LOG_COLOR(COLOR) "\033[0;" COLOR "m"
98 #define LOG_RESET_COLOR "\033[0m"
99 #define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED)
100 #define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN)
101 #define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN)
106 #define GLTH_LOGX(COLOR, LEVEL, LEVEL_STR, TAG, ...) \
108 if ((LEVEL) <= golioth_debug_get_log_level()) { \
109 uint64_t now_ms = golioth_time_millis(); \
110 printf(COLOR "%s (%" PRIu64 ") %s: ", LEVEL_STR, now_ms, TAG); \
111 printf(__VA_ARGS__); \
112 golioth_debug_printf(now_ms, LEVEL, TAG, __VA_ARGS__); \
113 printf("%s", LOG_RESET_COLOR); \
121 #define GLTH_LOGV(TAG, ...) \
122 GLTH_LOGX(LOG_COLOR_V, GOLIOTH_DEBUG_LOG_LEVEL_VERBOSE, "V", TAG, __VA_ARGS__)
126 #define GLTH_LOGD(TAG, ...) \
127 GLTH_LOGX(LOG_COLOR_D, GOLIOTH_DEBUG_LOG_LEVEL_DEBUG, "D", TAG, __VA_ARGS__)
131 #define GLTH_LOGI(TAG, ...) \
132 GLTH_LOGX(LOG_COLOR_I, GOLIOTH_DEBUG_LOG_LEVEL_INFO, "I", TAG, __VA_ARGS__)
136 #define GLTH_LOGW(TAG, ...) \
137 GLTH_LOGX(LOG_COLOR_W, GOLIOTH_DEBUG_LOG_LEVEL_WARN, "W", TAG, __VA_ARGS__)
141 #define GLTH_LOGE(TAG, ...) \
142 GLTH_LOGX(LOG_COLOR_E, GOLIOTH_DEBUG_LOG_LEVEL_ERROR, "E", TAG, __VA_ARGS__)
145 #ifndef GLTH_LOG_BUFFER_HEXDUMP
146 #define GLTH_LOG_BUFFER_HEXDUMP(TAG, payload, size, level) \
148 if ((level) <= golioth_debug_get_log_level()) { \
149 golioth_debug_hexdump(TAG, payload, size); \
156 #define GLTH_LOGV(TAG, ...)
157 #define GLTH_LOGD(TAG, ...)
158 #define GLTH_LOGI(TAG, ...)
159 #define GLTH_LOGW(TAG, ...)
160 #define GLTH_LOGE(TAG, ...)
161 #define GLTH_LOG_BUFFER_HEXDUMP(TAG, ...)
golioth_sys_sem_t golioth_sys_sem_create(uint32_t sem_max_count, uint32_t sem_initial_count)
bool golioth_sys_sem_give(golioth_sys_sem_t sem)
bool golioth_sys_timer_reset(golioth_sys_timer_t timer)
void * golioth_sys_thread_t
bool golioth_sys_timer_start(golioth_sys_timer_t timer)
bool golioth_sys_sem_take(golioth_sys_sem_t sem, int32_t ms_to_wait)
golioth_sys_timer_t golioth_sys_timer_create(golioth_sys_timer_config_t config)
void golioth_sys_timer_destroy(golioth_sys_timer_t timer)
void(* golioth_sys_thread_fn_t)(void *user_arg)
void golioth_sys_msleep(uint32_t ms)
void * golioth_sys_timer_t
golioth_sys_thread_t golioth_sys_thread_create(golioth_sys_thread_config_t config)
void(* golioth_sys_timer_fn_t)(golioth_sys_timer_t timer, void *user_arg)
void golioth_sys_thread_destroy(golioth_sys_thread_t thread)
uint64_t golioth_sys_now_ms(void)
void golioth_sys_sem_destroy(golioth_sys_sem_t sem)
golioth_sys_thread_fn_t fn
golioth_sys_timer_fn_t fn