diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-02-10 21:54:52 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-02-10 21:54:52 +0000 |
| commit | 548a919ea379a3b9d1d9e41cf4dad6b4779fd3e6 (patch) | |
| tree | 85666198fed3d4803f3ec3373c134d12bde9329b /src/engine/e_system.c | |
| parent | 2f969d9d6fece689e05857580ffb1843439e5fbb (diff) | |
| download | zcatch-548a919ea379a3b9d1d9e41cf4dad6b4779fd3e6.tar.gz zcatch-548a919ea379a3b9d1d9e41cf4dad6b4779fd3e6.zip | |
merged 0.3.4 changes to trunk
Diffstat (limited to 'src/engine/e_system.c')
| -rw-r--r-- | src/engine/e_system.c | 47 |
1 files changed, 47 insertions, 0 deletions
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 |