diff --git a/rtc_base/critical_section.cc b/rtc_base/critical_section.cc index 4a5c53b54d..9e3615ee0c 100644 --- a/rtc_base/critical_section.cc +++ b/rtc_base/critical_section.cc @@ -31,7 +31,7 @@ CriticalSection::CriticalSection() { #if defined(WEBRTC_WIN) InitializeCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) -#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC lock_queue_ = 0; owning_thread_ = 0; recursion_ = 0; @@ -60,7 +60,7 @@ CriticalSection::~CriticalSection() { #if defined(WEBRTC_WIN) DeleteCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) -#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC dispatch_release(semaphore_); #else pthread_mutex_destroy(&mutex_); @@ -74,7 +74,7 @@ void CriticalSection::Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION() { #if defined(WEBRTC_WIN) EnterCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) -#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC int spin = 3000; PlatformThreadRef self = CurrentThreadRef(); bool have_lock = false; @@ -133,7 +133,7 @@ bool CriticalSection::TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) { #if defined(WEBRTC_WIN) return TryEnterCriticalSection(&crit_) != FALSE; #elif defined(WEBRTC_POSIX) -#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC if (!IsThreadRefEqual(owning_thread_, CurrentThreadRef())) { if (AtomicOps::CompareAndSwap(&lock_queue_, 0, 1) != 0) return false; @@ -173,7 +173,7 @@ void CriticalSection::Leave() const RTC_UNLOCK_FUNCTION() { if (!recursion_count_) thread_ = 0; #endif -#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC RTC_DCHECK(IsThreadRefEqual(owning_thread_, CurrentThreadRef())); RTC_DCHECK_GE(recursion_, 0); --recursion_; @@ -217,14 +217,15 @@ CritScope::~CritScope() { } void GlobalLockPod::Lock() { -#if !defined(WEBRTC_WIN) && (!defined(WEBRTC_MAC) || USE_NATIVE_MUTEX_ON_MAC) +#if !defined(WEBRTC_WIN) && \ + (!defined(WEBRTC_MAC) || RTC_USE_NATIVE_MUTEX_ON_MAC) const struct timespec ts_null = {0}; #endif while (AtomicOps::CompareAndSwap(&lock_acquired, 0, 1)) { #if defined(WEBRTC_WIN) ::Sleep(0); -#elif defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#elif defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC sched_yield(); #else nanosleep(&ts_null, nullptr); diff --git a/rtc_base/critical_section.h b/rtc_base/critical_section.h index 4433529886..f9047a6b07 100644 --- a/rtc_base/critical_section.h +++ b/rtc_base/critical_section.h @@ -34,9 +34,9 @@ #endif // See notes in the 'Performance' unit test for the effects of this flag. -#define USE_NATIVE_MUTEX_ON_MAC 1 +#define RTC_USE_NATIVE_MUTEX_ON_MAC 1 -#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC #include #endif @@ -61,7 +61,7 @@ class RTC_LOCKABLE CriticalSection { #if defined(WEBRTC_WIN) mutable CRITICAL_SECTION crit_; #elif defined(WEBRTC_POSIX) -#if defined(WEBRTC_MAC) && !USE_NATIVE_MUTEX_ON_MAC +#if defined(WEBRTC_MAC) && !RTC_USE_NATIVE_MUTEX_ON_MAC // Number of times the lock has been locked + number of threads waiting. // TODO(tommi): We could use this number and subtract the recursion count // to find places where we have multiple threads contending on the same lock.