LOCAL_FN int clock_gettime(clockid_t clk_id, struct timespec *tp) { (void)clk_id; if (!tp) { errno = EFAULT; return -1; } gettimespec(tp); return 0; }
CL_BOOL CL_ThreadUnix::Wait(DWORD msec) { INT ret = 0; pthread_mutex_lock(&m_mutex); if (m_bSignalFlg == CL_FALSE) { if (INFINITE != msec) { #ifdef _FOR_APPLE_ struct timespec nptime; nptime.tv_sec = msec/ 1000; nptime.tv_nsec = msec% 1000*1000000; ret = pthread_cond_timedwait_relative_np(&m_cond, &m_mutex, &nptime); #elif defined(_FOR_ANDROID_) struct timespec nptime; gettimespec(&nptime, msec); ret = pthread_cond_timedwait_monotonic_np(&m_cond, &m_mutex, &nptime); #else // _LINUX struct timespec nptime; gettimespec(&nptime, msec); ret = pthread_cond_timedwait(&m_cond, &m_mutex, &nptime); #endif } else { ret = pthread_cond_wait(&m_cond, &m_mutex); } } m_bSignalFlg = CL_FALSE; pthread_mutex_unlock(&m_mutex); // DWORD *pAddr = NULL; // [0] timer id; [1] timer pointer. while (1) { m_cSyncMSg.SyncStart(); intptr_t* pAddr = (intptr_t*)m_cMsgQue.Pop(); m_cSyncMSg.SyncEnd(); if (pAddr != NULL) { if (CL_Timer::IsValid(*pAddr) == TRUE) { reinterpret_cast<CL_Timer*>(*(pAddr+1))->DoAction(); } delete[] pAddr; } else { break; } } // ETIMEDOUT if (0 == ret) { return CL_TRUE; } else { return CL_FALSE; } }