thread.h

来自「串口代理」· C头文件 代码 · 共 45 行

H
45
字号
#ifndef THREAD_H#define THREAD_H#if defined(__UNIX__)#  define PTHREADS#elif defined(__WIN32__)#  define WINTHREADS#endif#if defined(PTHREADS)#  include <pthread.h>typedef pthread_t thr_t;typedef pthread_mutex_t thr_mutex_t;typedef void * thr_exitcode_t;typedef void *(*thr_startfunc_ptr_t)(void *);typedef void * thr_startfunc_t;#elif defined(WINTHREADS)#  include <windows.h>typedef HANDLE thr_t;typedef HANDLE thr_mutex_t;typedef DWORD thr_exitcode_t;typedef LPTHREAD_START_ROUTINE thr_startfunc_ptr_t;#define thr_startfunc_t thr_exitcode_t WINAPI#endifint thr_create(thr_t *thread, int detached,			   thr_startfunc_ptr_t startfunc, void *arg);int thr_cancel(thr_t thread);void thr_exit(thr_exitcode_t retval);thr_t thr_self(void);int thr_equal(thr_t thread1, thr_t thread2);int thr_join(thr_t thread, thr_exitcode_t *retval);int thr_detach(thr_t thread);thr_mutex_t thr_mutex_create(void);int thr_mutex_destroy(thr_mutex_t *mutex);int thr_mutex_lock(thr_mutex_t *mutex);int thr_mutex_trylock(thr_mutex_t *mutex);int thr_mutex_unlock(thr_mutex_t *mutex);#endif	/* THREAD_H */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?