Revert of Rename thread annotation macros to have RTC prefix for syncrhonization primitives. (patchset #1 id:1 of https://codereview.webrtc.org/3004393002/ ) Reason for revert: Breaks chromium bots Original issue's description: > Rename thread annotation macros to have RTC prefix for syncrhonization primitives. > > other macros (e.g. GUARDED_BY) rename postpone to followup CL > since it touches codebase wider > > BUG=webrtc:8198 > > Review-Url: https://codereview.webrtc.org/3004393002 > Cr-Commit-Position: refs/heads/master@{#19701} > Committed: https://chromium.googlesource.com/external/webrtc/+/9a2d2dd973ea33ba551db09257441c7f6943bfe4 TBR=kwiberg@webrtc.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=webrtc:8198 Review-Url: https://codereview.webrtc.org/3008193002 Cr-Original-Commit-Position: refs/heads/master@{#19702} Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc Cr-Mirrored-Commit: 42a70e31d6b08355e5803f66433b043d5825b56f
diff --git a/modules/audio_device/linux/audio_device_alsa_linux.h b/modules/audio_device/linux/audio_device_alsa_linux.h index 034f083..2648465 100644 --- a/modules/audio_device/linux/audio_device_alsa_linux.h +++ b/modules/audio_device/linux/audio_device_alsa_linux.h
@@ -146,8 +146,8 @@ bool KeyPressed() const; - void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); }; - void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); }; + void Lock() EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); }; + void UnLock() UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); }; inline int32_t InputSanityCheckAfterUnlockedPeriod() const; inline int32_t OutputSanityCheckAfterUnlockedPeriod() const;
diff --git a/modules/audio_device/linux/audio_device_pulse_linux.h b/modules/audio_device/linux/audio_device_pulse_linux.h index ada275b..7e8d683 100644 --- a/modules/audio_device/linux/audio_device_pulse_linux.h +++ b/modules/audio_device/linux/audio_device_pulse_linux.h
@@ -199,10 +199,10 @@ void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override; private: - void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(_critSect) { + void Lock() EXCLUSIVE_LOCK_FUNCTION(_critSect) { _critSect.Enter(); } - void UnLock() RTC_UNLOCK_FUNCTION(_critSect) { + void UnLock() UNLOCK_FUNCTION(_critSect) { _critSect.Leave(); } void WaitForOperationCompletion(pa_operation* paOperation) const;
diff --git a/rtc_base/criticalsection.cc b/rtc_base/criticalsection.cc index 66d8dcf..08acb13 100644 --- a/rtc_base/criticalsection.cc +++ b/rtc_base/criticalsection.cc
@@ -56,7 +56,7 @@ #endif } -void CriticalSection::Enter() const { +void CriticalSection::Enter() const EXCLUSIVE_LOCK_FUNCTION() { #if defined(WEBRTC_WIN) EnterCriticalSection(&crit_); #elif defined(WEBRTC_POSIX) @@ -115,7 +115,7 @@ #endif } -bool CriticalSection::TryEnter() const { +bool CriticalSection::TryEnter() const EXCLUSIVE_TRYLOCK_FUNCTION(true) { #if defined(WEBRTC_WIN) return TryEnterCriticalSection(&crit_) != FALSE; #elif defined(WEBRTC_POSIX) @@ -148,7 +148,7 @@ #endif } -void CriticalSection::Leave() const { +void CriticalSection::Leave() const UNLOCK_FUNCTION() { RTC_DCHECK(CurrentThreadIsOwner()); #if defined(WEBRTC_WIN) LeaveCriticalSection(&crit_);
diff --git a/rtc_base/criticalsection.h b/rtc_base/criticalsection.h index fb55aaf..38172d7 100644 --- a/rtc_base/criticalsection.h +++ b/rtc_base/criticalsection.h
@@ -52,14 +52,14 @@ // Locking methods (Enter, TryEnter, Leave)are const to permit protecting // members inside a const context without requiring mutable CriticalSections // everywhere. -class RTC_LOCKABLE CriticalSection { +class LOCKABLE CriticalSection { public: CriticalSection(); ~CriticalSection(); - void Enter() const RTC_EXCLUSIVE_LOCK_FUNCTION(); - bool TryEnter() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true); - void Leave() const RTC_UNLOCK_FUNCTION(); + void Enter() const EXCLUSIVE_LOCK_FUNCTION(); + bool TryEnter() const EXCLUSIVE_TRYLOCK_FUNCTION(true); + void Leave() const UNLOCK_FUNCTION(); private: // Use only for RTC_DCHECKing. @@ -91,11 +91,10 @@ }; // CritScope, for serializing execution through a scope. -class RTC_SCOPED_LOCKABLE CritScope { +class SCOPED_LOCKABLE CritScope { public: - explicit CritScope(const CriticalSection* cs) RTC_EXCLUSIVE_LOCK_FUNCTION(cs); - ~CritScope() RTC_UNLOCK_FUNCTION(); - + explicit CritScope(const CriticalSection* cs) EXCLUSIVE_LOCK_FUNCTION(cs); + ~CritScope() UNLOCK_FUNCTION(); private: const CriticalSection* const cs_; RTC_DISALLOW_COPY_AND_ASSIGN(CritScope); @@ -128,11 +127,11 @@ // A POD lock used to protect global variables. Do NOT use for other purposes. // No custom constructor or private data member should be added. -class RTC_LOCKABLE GlobalLockPod { +class LOCKABLE GlobalLockPod { public: - void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION(); + void Lock() EXCLUSIVE_LOCK_FUNCTION(); - void Unlock() RTC_UNLOCK_FUNCTION(); + void Unlock() UNLOCK_FUNCTION(); volatile int lock_acquired; }; @@ -143,12 +142,10 @@ }; // GlobalLockScope, for serializing execution through a scope. -class RTC_SCOPED_LOCKABLE GlobalLockScope { +class SCOPED_LOCKABLE GlobalLockScope { public: - explicit GlobalLockScope(GlobalLockPod* lock) - RTC_EXCLUSIVE_LOCK_FUNCTION(lock); - ~GlobalLockScope() RTC_UNLOCK_FUNCTION(); - + explicit GlobalLockScope(GlobalLockPod* lock) EXCLUSIVE_LOCK_FUNCTION(lock); + ~GlobalLockScope() UNLOCK_FUNCTION(); private: GlobalLockPod* const lock_; RTC_DISALLOW_COPY_AND_ASSIGN(GlobalLockScope);
diff --git a/rtc_base/criticalsection_unittest.cc b/rtc_base/criticalsection_unittest.cc index c264e44..2e136bf 100644 --- a/rtc_base/criticalsection_unittest.cc +++ b/rtc_base/criticalsection_unittest.cc
@@ -113,10 +113,14 @@ int shared_value_; }; -class RTC_LOCKABLE CriticalSectionLock { +class LOCKABLE CriticalSectionLock { public: - void Lock() RTC_EXCLUSIVE_LOCK_FUNCTION() { cs_.Enter(); } - void Unlock() RTC_UNLOCK_FUNCTION() { cs_.Leave(); } + void Lock() EXCLUSIVE_LOCK_FUNCTION() { + cs_.Enter(); + } + void Unlock() UNLOCK_FUNCTION() { + cs_.Leave(); + } private: CriticalSection cs_;
diff --git a/rtc_base/messagequeue.cc b/rtc_base/messagequeue.cc index 3dd1142..883735c 100644 --- a/rtc_base/messagequeue.cc +++ b/rtc_base/messagequeue.cc
@@ -23,16 +23,16 @@ const int kMaxMsgLatency = 150; // 150 ms const int kSlowDispatchLoggingThreshold = 50; // 50 ms -class RTC_SCOPED_LOCKABLE MarkProcessingCritScope { +class SCOPED_LOCKABLE MarkProcessingCritScope { public: MarkProcessingCritScope(const CriticalSection* cs, size_t* processing) - RTC_EXCLUSIVE_LOCK_FUNCTION(cs) + EXCLUSIVE_LOCK_FUNCTION(cs) : cs_(cs), processing_(processing) { cs_->Enter(); *processing_ += 1; } - ~MarkProcessingCritScope() RTC_UNLOCK_FUNCTION() { + ~MarkProcessingCritScope() UNLOCK_FUNCTION() { *processing_ -= 1; cs_->Leave(); }
diff --git a/rtc_base/race_checker.h b/rtc_base/race_checker.h index f0506c8..b49db53 100644 --- a/rtc_base/race_checker.h +++ b/rtc_base/race_checker.h
@@ -23,14 +23,14 @@ // Best-effort race-checking implementation. This primitive uses no // synchronization at all to be as-fast-as-possible in the non-racy case. -class RTC_LOCKABLE RaceChecker { +class LOCKABLE RaceChecker { public: friend class internal::RaceCheckerScope; RaceChecker(); private: - bool Acquire() const RTC_EXCLUSIVE_LOCK_FUNCTION(); - void Release() const RTC_UNLOCK_FUNCTION(); + bool Acquire() const EXCLUSIVE_LOCK_FUNCTION(); + void Release() const UNLOCK_FUNCTION(); // Volatile to prevent code being optimized away in Acquire()/Release(). mutable volatile int access_count_ = 0; @@ -38,25 +38,25 @@ }; namespace internal { -class RTC_SCOPED_LOCKABLE RaceCheckerScope { +class SCOPED_LOCKABLE RaceCheckerScope { public: explicit RaceCheckerScope(const RaceChecker* race_checker) - RTC_EXCLUSIVE_LOCK_FUNCTION(race_checker); + EXCLUSIVE_LOCK_FUNCTION(race_checker); bool RaceDetected() const; - ~RaceCheckerScope() RTC_UNLOCK_FUNCTION(); + ~RaceCheckerScope() UNLOCK_FUNCTION(); private: const RaceChecker* const race_checker_; const bool race_check_ok_; }; -class RTC_SCOPED_LOCKABLE RaceCheckerScopeDoNothing { +class SCOPED_LOCKABLE RaceCheckerScopeDoNothing { public: explicit RaceCheckerScopeDoNothing(const RaceChecker* race_checker) - RTC_EXCLUSIVE_LOCK_FUNCTION(race_checker) {} + EXCLUSIVE_LOCK_FUNCTION(race_checker) {} - ~RaceCheckerScopeDoNothing() RTC_UNLOCK_FUNCTION() {} + ~RaceCheckerScopeDoNothing() UNLOCK_FUNCTION() {} }; } // namespace internal
diff --git a/rtc_base/sequenced_task_checker.h b/rtc_base/sequenced_task_checker.h index 59c4976..40b07f9 100644 --- a/rtc_base/sequenced_task_checker.h +++ b/rtc_base/sequenced_task_checker.h
@@ -14,7 +14,7 @@ // Apart from debug builds, we also enable the sequence checker in // builds with RTC_DCHECK_IS_ON so that trybots and waterfall bots // with this define will get the same level of checking as debug bots. -#define RTC_ENABLE_SEQUENCED_TASK_CHECKER RTC_DCHECK_IS_ON +#define ENABLE_SEQUENCED_TASK_CHECKER RTC_DCHECK_IS_ON #include "webrtc/rtc_base/checks.h" #include "webrtc/rtc_base/constructormagic.h" @@ -53,19 +53,18 @@ // } // // In Release mode, CalledOnValidThread will always return true. -#if RTC_ENABLE_SEQUENCED_TASK_CHECKER -class RTC_LOCKABLE SequencedTaskChecker : public SequencedTaskCheckerImpl {}; +#if ENABLE_SEQUENCED_TASK_CHECKER +class LOCKABLE SequencedTaskChecker : public SequencedTaskCheckerImpl {}; #else -class RTC_LOCKABLE SequencedTaskChecker : public SequencedTaskCheckerDoNothing { -}; -#endif // RTC_ENABLE_SEQUENCED_TASK_CHECKER_H_ +class LOCKABLE SequencedTaskChecker : public SequencedTaskCheckerDoNothing {}; +#endif // ENABLE_SEQUENCED_TASK_CHECKER_H_ namespace internal { -class RTC_SCOPED_LOCKABLE SequencedTaskCheckerScope { +class SCOPED_LOCKABLE SequencedTaskCheckerScope { public: explicit SequencedTaskCheckerScope(const SequencedTaskChecker* checker) - RTC_EXCLUSIVE_LOCK_FUNCTION(checker); - ~SequencedTaskCheckerScope() RTC_UNLOCK_FUNCTION(); + EXCLUSIVE_LOCK_FUNCTION(checker); + ~SequencedTaskCheckerScope() UNLOCK_FUNCTION(); }; } // namespace internal @@ -73,7 +72,7 @@ #define RTC_DCHECK_CALLED_SEQUENTIALLY(x) \ rtc::internal::SequencedTaskCheckerScope checker(x) -#undef RTC_ENABLE_SEQUENCED_TASK_CHECKER +#undef ENABLE_SEQUENCED_TASK_CHECKER } // namespace rtc #endif // WEBRTC_RTC_BASE_SEQUENCED_TASK_CHECKER_H_
diff --git a/rtc_base/signalthread.h b/rtc_base/signalthread.h index 1c6c876..f6722a7 100644 --- a/rtc_base/signalthread.h +++ b/rtc_base/signalthread.h
@@ -119,9 +119,9 @@ RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(Worker); }; - class RTC_SCOPED_LOCKABLE EnterExit { + class SCOPED_LOCKABLE EnterExit { public: - explicit EnterExit(SignalThread* t) RTC_EXCLUSIVE_LOCK_FUNCTION(t->cs_) + explicit EnterExit(SignalThread* t) EXCLUSIVE_LOCK_FUNCTION(t->cs_) : t_(t) { t_->cs_.Enter(); // If refcount_ is zero then the object has already been deleted and we @@ -129,7 +129,7 @@ RTC_DCHECK_NE(0, t_->refcount_); ++t_->refcount_; } - ~EnterExit() RTC_UNLOCK_FUNCTION() { + ~EnterExit() UNLOCK_FUNCTION() { bool d = (0 == --t_->refcount_); t_->cs_.Leave(); if (d)
diff --git a/rtc_base/task_queue.h b/rtc_base/task_queue.h index 08cde56..5dee6e6 100644 --- a/rtc_base/task_queue.h +++ b/rtc_base/task_queue.h
@@ -153,7 +153,7 @@ // TaskQueue itself has been deleted or it may happen synchronously while the // TaskQueue instance is being deleted. This may vary from one OS to the next // so assumptions about lifetimes of pending tasks should not be made. -class RTC_LOCKABLE TaskQueue { +class LOCKABLE TaskQueue { public: // TaskQueue priority levels. On some platforms these will map to thread // priorities, on others such as Mac and iOS, GCD queue priorities.
diff --git a/rtc_base/thread.h b/rtc_base/thread.h index d072fac..f037d8a 100644 --- a/rtc_base/thread.h +++ b/rtc_base/thread.h
@@ -100,7 +100,7 @@ // WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread(). -class RTC_LOCKABLE Thread : public MessageQueue { +class LOCKABLE Thread : public MessageQueue { public: // DEPRECATED. // The default constructor should not be used because it hides whether or
diff --git a/rtc_base/thread_annotations.h b/rtc_base/thread_annotations.h index 80e866a..175b6b6 100644 --- a/rtc_base/thread_annotations.h +++ b/rtc_base/thread_annotations.h
@@ -20,9 +20,9 @@ #define WEBRTC_RTC_BASE_THREAD_ANNOTATIONS_H_ #if defined(__clang__) && (!defined(SWIG)) -#define RTC_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) +#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) #else -#define RTC_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op +#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op #endif // Document if a shared variable/field needs to be protected by a lock. @@ -31,9 +31,11 @@ // indicates a shared variable should be guarded (by any lock). GUARDED_VAR // is primarily used when the client cannot express the name of the lock. #if !defined(GUARDED_BY) -#define GUARDED_BY(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) +#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) #endif -#define RTC_GUARDED_VAR RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_var) +#if !defined(GUARDED_VAR) +#define GUARDED_VAR THREAD_ANNOTATION_ATTRIBUTE__(guarded_var) +#endif // Document if the memory location pointed to by a pointer should be guarded // by a lock when dereferencing the pointer. Similar to GUARDED_VAR, @@ -43,8 +45,12 @@ // q, which is guarded by mu1, points to a shared memory location that is // guarded by mu2, q should be annotated as follows: // int *q GUARDED_BY(mu1) PT_GUARDED_BY(mu2); -#define RTC_PT_GUARDED_BY(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) -#define RTC_PT_GUARDED_VAR RTC_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var) +#if !defined(PT_GUARDED_BY) +#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) +#endif +#if !defined(PT_GUARDED_VAR) +#define PT_GUARDED_VAR THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var) +#endif // Document the acquisition order between locks that can be held // simultaneously by a thread. For any two locks that need to be annotated @@ -52,10 +58,10 @@ // (i.e. You don't have to annotate both locks with both ACQUIRED_AFTER // and ACQUIRED_BEFORE.) #if !defined(ACQUIRED_AFTER) -#define ACQUIRED_AFTER(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x)) +#define ACQUIRED_AFTER(x) THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x)) #endif #if !defined(ACQUIRED_BEFORE) -#define ACQUIRED_BEFORE(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x)) +#define ACQUIRED_BEFORE(x) THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x)) #endif // The following three annotations document the lock requirements for @@ -64,12 +70,12 @@ // Document if a function expects certain locks to be held before it is called #if !defined(EXCLUSIVE_LOCKS_REQUIRED) #define EXCLUSIVE_LOCKS_REQUIRED(...) \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__)) + THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__)) #endif #if !defined(SHARED_LOCKS_REQUIRED) #define SHARED_LOCKS_REQUIRED(...) \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__)) + THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__)) #endif // Document the locks acquired in the body of the function. These locks @@ -77,38 +83,54 @@ // non-reentrant). #if !defined(LOCKS_EXCLUDED) #define LOCKS_EXCLUDED(...) \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) + THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(__VA_ARGS__)) #endif // Document the lock the annotated function returns without acquiring it. -#define RTC_LOCK_RETURNED(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) +#if !defined(LOCK_RETURNED) +#define LOCK_RETURNED(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) +#endif // Document if a class/type is a lockable type (such as the Mutex class). -#define RTC_LOCKABLE RTC_THREAD_ANNOTATION_ATTRIBUTE__(lockable) +#if !defined(LOCKABLE) +#define LOCKABLE THREAD_ANNOTATION_ATTRIBUTE__(lockable) +#endif // Document if a class is a scoped lockable type (such as the MutexLock class). -#define RTC_SCOPED_LOCKABLE RTC_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) +#if !defined(SCOPED_LOCKABLE) +#define SCOPED_LOCKABLE THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) +#endif // The following annotations specify lock and unlock primitives. -#define RTC_EXCLUSIVE_LOCK_FUNCTION(...) \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__)) +#if !defined(EXCLUSIVE_LOCK_FUNCTION) +#define EXCLUSIVE_LOCK_FUNCTION(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__)) +#endif -#define RTC_SHARED_LOCK_FUNCTION(...) \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__)) +#if !defined(SHARED_LOCK_FUNCTION) +#define SHARED_LOCK_FUNCTION(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__)) +#endif -#define RTC_EXCLUSIVE_TRYLOCK_FUNCTION(...) \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) +#if !defined(EXCLUSIVE_TRYLOCK_FUNCTION) +#define EXCLUSIVE_TRYLOCK_FUNCTION(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) +#endif -#define RTC_SHARED_TRYLOCK_FUNCTION(...) \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) +#if !defined(SHARED_TRYLOCK_FUNCTION) +#define SHARED_TRYLOCK_FUNCTION(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) +#endif -#define RTC_UNLOCK_FUNCTION(...) \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) +#if !defined(UNLOCK_FUNCTION) +#define UNLOCK_FUNCTION(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) +#endif // An escape hatch for thread safety analysis to ignore the annotated function. #if !defined(NO_THREAD_SAFETY_ANALYSIS) #define NO_THREAD_SAFETY_ANALYSIS \ - RTC_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) + THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) #endif #endif // WEBRTC_RTC_BASE_THREAD_ANNOTATIONS_H_
diff --git a/rtc_base/thread_annotations_unittest.cc b/rtc_base/thread_annotations_unittest.cc index 92fbafe..a8ff014 100644 --- a/rtc_base/thread_annotations_unittest.cc +++ b/rtc_base/thread_annotations_unittest.cc
@@ -13,21 +13,19 @@ namespace { -class RTC_LOCKABLE Lock { +class LOCKABLE Lock { public: - void EnterWrite() const RTC_EXCLUSIVE_LOCK_FUNCTION() {} - void EnterRead() const RTC_SHARED_LOCK_FUNCTION() {} - bool TryEnterWrite() const RTC_EXCLUSIVE_TRYLOCK_FUNCTION(true) { - return true; - } - bool TryEnterRead() const RTC_SHARED_TRYLOCK_FUNCTION(true) { return true; } - void Leave() const RTC_UNLOCK_FUNCTION() {} + void EnterWrite() const EXCLUSIVE_LOCK_FUNCTION() {} + void EnterRead() const SHARED_LOCK_FUNCTION() {} + bool TryEnterWrite() const EXCLUSIVE_TRYLOCK_FUNCTION(true) { return true; } + bool TryEnterRead() const SHARED_TRYLOCK_FUNCTION(true) { return true; } + void Leave() const UNLOCK_FUNCTION() {} }; -class RTC_SCOPED_LOCKABLE ScopeLock { +class SCOPED_LOCKABLE ScopeLock { public: - explicit ScopeLock(const Lock& lock) RTC_EXCLUSIVE_LOCK_FUNCTION(lock) {} - ~ScopeLock() RTC_UNLOCK_FUNCTION() {} + explicit ScopeLock(const Lock& lock) EXCLUSIVE_LOCK_FUNCTION(lock) {} + ~ScopeLock() UNLOCK_FUNCTION() {} }; class ThreadSafe { @@ -123,7 +121,7 @@ protected_by_lock_ = unprotected_; } - const Lock& GetLock() RTC_LOCK_RETURNED(lock_) { return lock_; } + const Lock& GetLock() LOCK_RETURNED(lock_) { return lock_; } Lock anylock_ ACQUIRED_BEFORE(lock_); Lock lock_; @@ -132,10 +130,10 @@ int unprotected_ = 0; int protected_by_lock_ GUARDED_BY(lock_) = 0; - int protected_by_anything_ RTC_GUARDED_VAR = 0; + int protected_by_anything_ GUARDED_VAR = 0; - int* pt_protected_by_lock_ RTC_PT_GUARDED_BY(pt_lock_); - int* pt_protected_by_anything_ RTC_PT_GUARDED_VAR; + int* pt_protected_by_lock_ PT_GUARDED_BY(pt_lock_); + int* pt_protected_by_anything_ PT_GUARDED_VAR; }; } // namespace
diff --git a/rtc_base/thread_checker.h b/rtc_base/thread_checker.h index 824ebe5..b6ce017 100644 --- a/rtc_base/thread_checker.h +++ b/rtc_base/thread_checker.h
@@ -71,20 +71,22 @@ // // In Release mode, CalledOnValidThread will always return true. #if ENABLE_THREAD_CHECKER -class RTC_LOCKABLE ThreadChecker : public ThreadCheckerImpl {}; +class LOCKABLE ThreadChecker : public ThreadCheckerImpl { +}; #else -class RTC_LOCKABLE ThreadChecker : public ThreadCheckerDoNothing {}; +class LOCKABLE ThreadChecker : public ThreadCheckerDoNothing { +}; #endif // ENABLE_THREAD_CHECKER #undef ENABLE_THREAD_CHECKER namespace internal { -class RTC_SCOPED_LOCKABLE AnnounceOnThread { +class SCOPED_LOCKABLE AnnounceOnThread { public: - template <typename ThreadLikeObject> + template<typename ThreadLikeObject> explicit AnnounceOnThread(const ThreadLikeObject* thread_like_object) - RTC_EXCLUSIVE_LOCK_FUNCTION(thread_like_object) {} - ~AnnounceOnThread() RTC_UNLOCK_FUNCTION() {} + EXCLUSIVE_LOCK_FUNCTION(thread_like_object) {} + ~AnnounceOnThread() UNLOCK_FUNCTION() {} template<typename ThreadLikeObject> static bool IsCurrent(const ThreadLikeObject* thread_like_object) { @@ -164,10 +166,10 @@ // Document if a variable/field is not shared and should be accessed from // same thread/task queue. -#define ACCESS_ON(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) +#define ACCESS_ON(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) // Document if a function expected to be called from same thread/task queue. -#define RUN_ON(x) RTC_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(x)) +#define RUN_ON(x) THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(x)) #define RTC_DCHECK_RUN_ON(thread_like_object) \ rtc::internal::AnnounceOnThread thread_announcer(thread_like_object); \
diff --git a/system_wrappers/include/rw_lock_wrapper.h b/system_wrappers/include/rw_lock_wrapper.h index 62e75b4..855ecff 100644 --- a/system_wrappers/include/rw_lock_wrapper.h +++ b/system_wrappers/include/rw_lock_wrapper.h
@@ -19,41 +19,45 @@ namespace webrtc { -class RTC_LOCKABLE RWLockWrapper { +class LOCKABLE RWLockWrapper { public: static RWLockWrapper* CreateRWLock(); virtual ~RWLockWrapper() {} - virtual void AcquireLockExclusive() RTC_EXCLUSIVE_LOCK_FUNCTION() = 0; - virtual void ReleaseLockExclusive() RTC_UNLOCK_FUNCTION() = 0; + virtual void AcquireLockExclusive() EXCLUSIVE_LOCK_FUNCTION() = 0; + virtual void ReleaseLockExclusive() UNLOCK_FUNCTION() = 0; - virtual void AcquireLockShared() RTC_SHARED_LOCK_FUNCTION() = 0; - virtual void ReleaseLockShared() RTC_UNLOCK_FUNCTION() = 0; + virtual void AcquireLockShared() SHARED_LOCK_FUNCTION() = 0; + virtual void ReleaseLockShared() UNLOCK_FUNCTION() = 0; }; // RAII extensions of the RW lock. Prevents Acquire/Release missmatches and // provides more compact locking syntax. -class RTC_SCOPED_LOCKABLE ReadLockScoped { +class SCOPED_LOCKABLE ReadLockScoped { public: - ReadLockScoped(RWLockWrapper& rw_lock) RTC_SHARED_LOCK_FUNCTION(rw_lock) + ReadLockScoped(RWLockWrapper& rw_lock) SHARED_LOCK_FUNCTION(rw_lock) : rw_lock_(rw_lock) { rw_lock_.AcquireLockShared(); } - ~ReadLockScoped() RTC_UNLOCK_FUNCTION() { rw_lock_.ReleaseLockShared(); } + ~ReadLockScoped() UNLOCK_FUNCTION() { + rw_lock_.ReleaseLockShared(); + } private: RWLockWrapper& rw_lock_; }; -class RTC_SCOPED_LOCKABLE WriteLockScoped { +class SCOPED_LOCKABLE WriteLockScoped { public: - WriteLockScoped(RWLockWrapper& rw_lock) RTC_EXCLUSIVE_LOCK_FUNCTION(rw_lock) + WriteLockScoped(RWLockWrapper& rw_lock) EXCLUSIVE_LOCK_FUNCTION(rw_lock) : rw_lock_(rw_lock) { rw_lock_.AcquireLockExclusive(); } - ~WriteLockScoped() RTC_UNLOCK_FUNCTION() { rw_lock_.ReleaseLockExclusive(); } + ~WriteLockScoped() UNLOCK_FUNCTION() { + rw_lock_.ReleaseLockExclusive(); + } private: RWLockWrapper& rw_lock_;