clib/tthread.h
2023-10-22 21:43:47 +08:00

36 lines
620 B
C

#ifndef _TTHERAD_H_
#define _TTHREAD_H_
#include "sysenv.h"
#if _OS_WIN
#include <windows.h>
#define TID LPDWORD
#elif _OS_LINUX
#include <unistd.h>
#include <pthread.h>
#include <strings.h>
#define TID pthread_t
#else
#error "Not Supported Operator System"
#endif
#ifdef __cplusplus
extern "C" {
#endif
static inline void tthread_create(TID* tid,void(*thread_func)(void*), void* data) {
#if _OS_WIN
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_func, data, 0, tid);
#elif _OS_LINUX
pthread_create(tid, 0, (void*(*)(void*))thread_func, data);
#endif
}
#ifdef __cplusplus
}
#endif
#endif //_TTHREAD_H_