diff --git a/src/sbbs3/answer.cpp b/src/sbbs3/answer.cpp index 5e0c29ce1d955596060a048df7a076bcd29acf79..8388eb4d79924cb6e4eb694791a5834f43bd0ac3 100644 --- a/src/sbbs3/answer.cpp +++ b/src/sbbs3/answer.cpp @@ -132,9 +132,7 @@ bool sbbs_t::answer() strcat(str,COPYRIGHT_NOTICE); strip_ctrl(str); center(str); - #if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); - #endif + YIELD(); while(i++<50 && l<(int)sizeof(str)-1) { /* wait up to 5 seconds for response */ c=(incom()&0x7f); diff --git a/src/sbbs3/inkey.cpp b/src/sbbs3/inkey.cpp index f5604bdaad5ab858fdc5baf28fc1f964d6cf9e3f..90592c7ecee9f83b484188b57f8d20dc7e8aeab9 100644 --- a/src/sbbs3/inkey.cpp +++ b/src/sbbs3/inkey.cpp @@ -49,9 +49,7 @@ char sbbs_t::inkey(long mode) { uchar ch=0; - #if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); - #endif + YIELD(); if(keybuftop!=keybufbot) { ch=keybuf[keybufbot++]; diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index 37a7754d18903ee229ea4dd994b401795c7a0577..fbec34cbe795d92696ece4366fe61f4691d887d5 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -985,9 +985,7 @@ void input_thread(void *arg) while(sbbs->online && sbbs->client_socket!=INVALID_SOCKET && node_socket[sbbs->cfg.node_num-1]!=INVALID_SOCKET) { - #if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); - #endif + YIELD(); pthread_mutex_lock(&sbbs->input_thread_mutex); #ifdef __unix__ @@ -1201,9 +1199,7 @@ void output_thread(void* arg) sbbs->console|=CON_R_ECHO; while(sbbs->client_socket!=INVALID_SOCKET && telnet_socket!=INVALID_SOCKET) { - #if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); - #endif + YIELD(); if(bufbot==buftop) avail=RingBufFull(&sbbs->outbuf); @@ -2722,9 +2718,7 @@ int sbbs_t::incom(void) { uchar ch; -#if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); -#endif + YIELD(); if(!RingBufRead(&inbuf, &ch, 1)) return(NOINP); #if 0 // removed Jan-2003 @@ -2743,9 +2737,7 @@ int sbbs_t::outcom(uchar ch) return(TXBOF); sem_post(&output_sem); return(0); -#if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); -#endif + YIELD(); } void sbbs_t::putcom(char *str, int len) @@ -3094,9 +3086,7 @@ void node_thread(void* arg) if(sbbs->exec(&sbbs->main_csi)) break; - #if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); - #endif + YIELD(); } } @@ -3824,9 +3814,7 @@ void DLLCALL bbs_thread(void* arg) } while(telnet_socket!=INVALID_SOCKET) { - #if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); - #endif + YIELD(); if(node_threads_running==0 && !event_mutex_locked) { /* check for re-run flags */ bool rerun=false; diff --git a/src/sbbs3/ringbuf.c b/src/sbbs3/ringbuf.c index f49590729163fe0b80cca99dd0f5aace933ce352..06eab9c925d00ce342cae689957633d320a584d0 100644 --- a/src/sbbs3/ringbuf.c +++ b/src/sbbs3/ringbuf.c @@ -186,9 +186,7 @@ DWORD RINGBUFCALL RingBufWrite( RingBuf* rb, BYTE* src, DWORD cnt ) pthread_mutex_unlock(&rb->mutex); #endif -#if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); -#endif + YIELD(); return(cnt); } @@ -198,9 +196,7 @@ DWORD RINGBUFCALL RingBufRead( RingBuf* rb, BYTE* dst, DWORD cnt ) { DWORD max, first, remain, len; -#if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); -#endif + YIELD(); len = RingBufFull( rb ); if( len == 0 ) @@ -252,9 +248,7 @@ DWORD RINGBUFCALL RingBufPeek( RingBuf* rb, BYTE* dst, DWORD cnt) { DWORD max, first, remain, len; -#if defined(_PTH_H_) /* Cooperative multitasking! */ - pth_yield(NULL); -#endif + YIELD(); len = RingBufFull( rb ); if( len == 0 ) diff --git a/src/xpdev/genwrap.h b/src/xpdev/genwrap.h index b8aedaf3cceec5693600dd4a3f11639e4bf4faae..2b1da26deeeab028ea2ba90fa413a018730370e7 100644 --- a/src/xpdev/genwrap.h +++ b/src/xpdev/genwrap.h @@ -176,11 +176,11 @@ extern "C" { #ifndef SLEEP #ifndef SBBS - #define pthread_yield() + #define YIELD() #endif #define SLEEP(x) ({ int y=x; struct timeval tv; \ tv.tv_sec=(y/1000); tv.tv_usec=((y%1000)*1000); \ - pthread_yield(); \ + YIELD(); \ select(0,NULL,NULL,NULL,&tv); }) #endif #define BEEP(freq,dur) unix_beep(freq,dur) diff --git a/src/xpdev/threadwrap.h b/src/xpdev/threadwrap.h index 6f414977f57fc4a1c4033b3e834d5aa622b35ebc..104fd9b00e221f7dbc3f6f893b4c0083535853fd 100644 --- a/src/xpdev/threadwrap.h +++ b/src/xpdev/threadwrap.h @@ -49,6 +49,11 @@ extern "C" { #include <sys/param.h> #include <pthread.h> /* POSIX threads and mutexes */ +#ifdef __linux__ + #define YIELD() sched_yield() +#else + #define YIELD() pthread_yield() +#endif #if defined(_NEED_SEM) #include "sem.h" #else @@ -122,6 +127,7 @@ extern "C" { #define SLEEP(x) ({ int y=x; struct timeval tv; \ tv.tv_sec=(y/1000); tv.tv_usec=((y%1000)*1000); \ pth_nap(tv); }) +#define YIELD() pth_yield(NULL) #endif #endif /* Don't add anything after this line */