From 548a919ea379a3b9d1d9e41cf4dad6b4779fd3e6 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sun, 10 Feb 2008 21:54:52 +0000 Subject: merged 0.3.4 changes to trunk --- src/engine/e_system.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/engine/e_system.c') diff --git a/src/engine/e_system.c b/src/engine/e_system.c index c175f7c9..9a8b2a94 100644 --- a/src/engine/e_system.c +++ b/src/engine/e_system.c @@ -268,6 +268,45 @@ int io_close(IOHANDLE io) return 1; } +void *thread_create(void (*threadfunc)(void *), void *u) +{ +#if defined(CONF_FAMILY_UNIX) + pthread_t id; + pthread_create(&id, NULL, (void *(*)(void*))threadfunc, u); + return (void*)id; +#elif defined(CONF_FAMILY_WINDOWS) + return CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)threadfunc, u, 0, NULL); +#else + #error not implemented +#endif +} + +void thread_wait(void *thread) +{ +#if defined(CONF_FAMILY_UNIX) + pthread_join((pthread_t)thread, NULL); +#elif defined(CONF_FAMILY_WINDOWS) + WaitForSingleObject((HANDLE)thread, INFINITE); +#else + #error not implemented +#endif +} + +void thread_destroy(void *thread) +{ +} + +void thread_yield() +{ +#if defined(CONF_FAMILY_UNIX) + sched_yield(); +#elif defined(CONF_FAMILY_WINDOWS) + Sleep(0); +#else + #error not implemented +#endif +} + void thread_sleep(int milliseconds) { #if defined(CONF_FAMILY_UNIX) @@ -279,6 +318,9 @@ void thread_sleep(int milliseconds) #endif } + + + #if defined(CONF_FAMILY_UNIX) typedef pthread_mutex_t LOCKINTERNAL; #elif defined(CONF_FAMILY_WINDOWS) @@ -757,6 +799,11 @@ int net_socket_read_wait(NETSOCKET sock, int time) #endif*/ } +unsigned time_timestamp() +{ + return time(0); +} + #if defined(__cplusplus) } #endif -- cgit 1.4.1