csnake/include/platform/thread.h

30 lines
554 B
C
Raw Normal View History

#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
#endif /* _WIN32 */
typedef ThreadR (*Thread)(void *);
static inline void threadCreate(Thread function, void *args)
{
2023-12-01 23:11:01 +03:00
#ifdef _WIN32
_beginthread(function, 0, args);
#else
pthread_create(&(pthread_t){0}, 0, function, args);
#endif /* _WIN32 */
2023-12-01 23:11:01 +03:00
}
#endif /* __THREAD_H__ */