X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Funix%2Fsilcunixthread.c;h=575c54a894a8b8d4f09210b11d8c0ed9cc0d0df9;hb=99865727f85eb96f5462158eed8dc935710d1a0b;hp=7751603f61d68c11bbe62cbaa24253565f77015f;hpb=e4b63806b89601e4e787c239b39b1bee33e46f7e;p=silc.git diff --git a/lib/silcutil/unix/silcunixthread.c b/lib/silcutil/unix/silcunixthread.c index 7751603f..575c54a8 100644 --- a/lib/silcutil/unix/silcunixthread.c +++ b/lib/silcutil/unix/silcunixthread.c @@ -21,11 +21,10 @@ #include "silcincludes.h" -#ifdef SILC_THREADS - SilcThread silc_thread_create(SilcThreadStart start_func, void *context, bool waitable) { +#ifdef SILC_THREADS pthread_attr_t attr; pthread_t thread; int ret; @@ -61,25 +60,38 @@ SilcThread silc_thread_create(SilcThreadStart start_func, void *context, SILC_LOG_DEBUG(("Created thread %p", (SilcThread)thread)); return (SilcThread)thread; +#else + /* Call thread callback immediately */ + (*start_func)(context); + return NULL; +#endif } void silc_thread_exit(void *exit_value) { +#ifdef SILC_THREADS pthread_exit(exit_value); +#endif } SilcThread silc_thread_self(void) { +#ifdef SILC_THREADS pthread_t self = pthread_self(); return (SilcThread)self; +#else + return NULL; +#endif } bool silc_thread_wait(SilcThread thread, void **exit_value) { +#ifdef SILC_THREADS SILC_LOG_DEBUG(("Waiting for thread %p", thread)); if (!pthread_join(*(pthread_t *)thread, exit_value)) return TRUE; return FALSE; +#else + return FALSE; +#endif } - -#endif /* SILC_THREADS */