+ return HandleLockResult(pthread_mutex_lock(&m_mutex));
+}
+
+wxMutexError wxMutexInternal::Lock(unsigned long ms)
+{
+ static const long MSEC_IN_SEC = 1000;
+ static const long NSEC_IN_MSEC = 1000000;
+ static const long NSEC_IN_SEC = MSEC_IN_SEC * NSEC_IN_MSEC;
+
+ time_t seconds = ms/MSEC_IN_SEC;
+ long nanoseconds = (ms % MSEC_IN_SEC) * NSEC_IN_MSEC;
+ timespec ts = { 0, 0 };
+
+ if ( clock_gettime(CLOCK_REALTIME, &ts) == 0 )
+ {
+ ts.tv_sec += seconds;
+ ts.tv_nsec += nanoseconds;
+ if ( ts.tv_nsec > NSEC_IN_SEC )
+ {
+ ts.tv_sec += 1;
+ ts.tv_nsec -= NSEC_IN_SEC;
+ }
+ }
+ else // fall back on system timer
+ {
+ wxLogDebug(_T("clock_gettime(CLOCK_REALTIME) failed"));
+ ts.tv_sec = time(NULL) + seconds;
+ ts.tv_nsec = nanoseconds;
+ }
+
+ return HandleLockResult(pthread_mutex_timedlock(&m_mutex, &ts));
+}
+
+wxMutexError wxMutexInternal::HandleLockResult(int err)
+{