29 #ifndef _CSP_THREAD_H_ 30 #define _CSP_THREAD_H_ 40 #if defined(CSP_POSIX) || defined(CSP_MACOSX) 45 #define csp_thread_exit() pthread_exit(NULL) 47 typedef pthread_t csp_thread_handle_t;
48 typedef void * csp_thread_return_t;
50 #define CSP_DEFINE_TASK(task_name) csp_thread_return_t task_name(void * param) 51 #define CSP_TASK_RETURN NULL 53 #define csp_sleep_ms(time_ms) usleep(time_ms * 1000); 58 #if defined(CSP_WINDOWS) 64 #define csp_thread_exit() _endthreadex(0) 66 typedef HANDLE csp_thread_handle_t;
67 typedef unsigned int csp_thread_return_t;
69 #define CSP_DEFINE_TASK(task_name) csp_thread_return_t __attribute__((stdcall)) task_name(void * param) 70 #define CSP_TASK_RETURN 0 72 #define csp_sleep_ms(time_ms) Sleep(time_ms); 77 #if defined(CSP_FREERTOS) 82 #if INCLUDE_vTaskDelete 83 #define csp_thread_exit() vTaskDelete(NULL) 85 #define csp_thread_exit() 88 typedef xTaskHandle csp_thread_handle_t;
89 typedef void csp_thread_return_t;
91 #define CSP_DEFINE_TASK(task_name) csp_thread_return_t task_name(void * param) 92 #define CSP_TASK_RETURN 94 #define csp_sleep_ms(time_ms) vTaskDelay(time_ms / portTICK_RATE_MS); 96 #endif // CSP_FREERTOS 99 int csp_thread_create(csp_thread_return_t (* routine)(
void *),
const char *
const thread_name,
unsigned short stack_depth,
void * parameters,
unsigned int priority, csp_thread_handle_t * handle);
101 int csp_thread_create(csp_thread_return_t (* routine)(
void *)__attribute__((stdcall)),
const char *
const thread_name,
unsigned short stack_depth,
void * parameters,
unsigned int priority, csp_thread_handle_t * handle);
108 #endif // _CSP_THREAD_H_
int csp_thread_create(csp_thread_return_t(*routine)(void *), const char *const thread_name, unsigned short stack_depth, void *parameters, unsigned int priority, csp_thread_handle_t *handle)