void WA_lock(WA_recursiveLock _lock) #endif { NSAPIThreadRecursiveLock *lock = (NSAPIThreadRecursiveLock *)_lock; SYS_THREAD self = systhread_current(); #ifdef EXTRA_DEBUGGING_LOGS if (_lock != logMutex) WOLog(WO_DBG, " locking %s from %s:%d", lock->name, file, line); #endif crit_enter(lock->crit); while (lock->lockingThread != self && lock->lockCount != 0) condvar_wait(lock->condvar); lock->lockingThread = self; lock->lockCount++; crit_exit(lock->crit); }
/* Obtain the current thread id */ TSRM_API THREAD_T tsrm_thread_id(void) { #ifdef TSRM_WIN32 return GetCurrentThreadId(); #elif defined(GNUPTH) return pth_self(); #elif defined(PTHREADS) return pthread_self(); #elif defined(NSAPI) return systhread_current(); #elif defined(PI3WEB) return PIThread_getCurrent(); #elif defined(TSRM_ST) return st_thread_self(); #elif defined(BETHREADS) return find_thread(NULL); #endif }