2023-12-01 22:39:38 +03:00
|
|
|
#ifndef __THREAD_H__
|
|
|
|
#define __THREAD_H__
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <process.h>
|
|
|
|
#else
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
typedef void ThreadR;
|
|
|
|
#define ThreadReturn return
|
|
|
|
#else
|
|
|
|
typedef void* ThreadR;
|
2023-12-01 22:46:43 +03:00
|
|
|
#define ThreadReturn return NULL
|
2023-12-01 22:39:38 +03:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
typedef ThreadR (*Thread)(void *);
|
|
|
|
|
|
|
|
static inline void threadCreate(Thread function, void *args)
|
|
|
|
{
|
2023-12-01 23:11:01 +03:00
|
|
|
#ifdef _WIN32
|
2023-12-01 22:39:38 +03:00
|
|
|
_beginthread(function, 0, args);
|
|
|
|
#else
|
|
|
|
pthread_create(&(pthread_t){0}, 0, function, args);
|
|
|
|
#endif /* _WIN32 */
|
2023-12-01 23:11:01 +03:00
|
|
|
}
|
2023-12-01 22:39:38 +03:00
|
|
|
|
|
|
|
#endif /* __THREAD_H__ */
|