diff --git a/talk/session/media/srtpfilter.cc b/talk/session/media/srtpfilter.cc index dc93dd463d..b47844f2ee 100644 --- a/talk/session/media/srtpfilter.cc +++ b/talk/session/media/srtpfilter.cc @@ -770,7 +770,7 @@ void SrtpSession::HandleEventThunk(srtp_event_data_t* ev) { } std::list* SrtpSession::sessions() { - LIBJINGLE_DEFINE_STATIC_LOCAL(std::list, sessions, ()); + RTC_DEFINE_STATIC_LOCAL(std::list, sessions, ()); return &sessions; } diff --git a/webrtc/base/basictypes.h b/webrtc/base/basictypes.h index 6299061e14..3edf3548ef 100644 --- a/webrtc/base/basictypes.h +++ b/webrtc/base/basictypes.h @@ -111,14 +111,16 @@ typedef int socklen_t; // The following only works for C++ #ifdef __cplusplus +#ifndef ALIGNP #define ALIGNP(p, t) \ (reinterpret_cast(((reinterpret_cast(p) + \ ((t) - 1)) & ~((t) - 1)))) +#endif #define RTC_IS_ALIGNED(p, a) (!((uintptr_t)(p) & ((a) - 1))) // Use these to declare and define a static local variable (static T;) so that // it is leaked so that its destructors are not called at exit. -#define LIBJINGLE_DEFINE_STATIC_LOCAL(type, name, arguments) \ +#define RTC_DEFINE_STATIC_LOCAL(type, name, arguments) \ static type& name = *new type arguments #endif // __cplusplus diff --git a/webrtc/base/helpers.cc b/webrtc/base/helpers.cc index bd7ff96ac4..9012c335c8 100644 --- a/webrtc/base/helpers.cc +++ b/webrtc/base/helpers.cc @@ -180,8 +180,8 @@ namespace { // This round about way of creating a global RNG is to safe-guard against // indeterminant static initialization order. scoped_ptr& GetGlobalRng() { - LIBJINGLE_DEFINE_STATIC_LOCAL(scoped_ptr, global_rng, - (new SecureRandomGenerator())); + RTC_DEFINE_STATIC_LOCAL(scoped_ptr, global_rng, + (new SecureRandomGenerator())); return global_rng; } diff --git a/webrtc/base/physicalsocketserver.cc b/webrtc/base/physicalsocketserver.cc index bc3fb32dd9..b9c2a07aa5 100644 --- a/webrtc/base/physicalsocketserver.cc +++ b/webrtc/base/physicalsocketserver.cc @@ -622,7 +622,7 @@ class PosixSignalHandler { // sort of user-defined void * parameter, so they can't access anything that // isn't global.) static PosixSignalHandler* Instance() { - LIBJINGLE_DEFINE_STATIC_LOCAL(PosixSignalHandler, instance, ()); + RTC_DEFINE_STATIC_LOCAL(PosixSignalHandler, instance, ()); return &instance; } diff --git a/webrtc/base/profiler.cc b/webrtc/base/profiler.cc index e0bd431cf6..9f781fbe14 100644 --- a/webrtc/base/profiler.cc +++ b/webrtc/base/profiler.cc @@ -89,7 +89,7 @@ double ProfilerEvent::standard_deviation() const { Profiler::~Profiler() = default; Profiler* Profiler::Instance() { - LIBJINGLE_DEFINE_STATIC_LOCAL(Profiler, instance, ()); + RTC_DEFINE_STATIC_LOCAL(Profiler, instance, ()); return &instance; } diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc index 21109fadcd..48a914451d 100644 --- a/webrtc/base/thread.cc +++ b/webrtc/base/thread.cc @@ -36,7 +36,7 @@ namespace rtc { ThreadManager* ThreadManager::Instance() { - LIBJINGLE_DEFINE_STATIC_LOCAL(ThreadManager, thread_manager, ()); + RTC_DEFINE_STATIC_LOCAL(ThreadManager, thread_manager, ()); return &thread_manager; } diff --git a/webrtc/common.h b/webrtc/common.h index 6ead4098d3..d0d7eb192c 100644 --- a/webrtc/common.h +++ b/webrtc/common.h @@ -13,6 +13,8 @@ #include +#include "webrtc/base/basictypes.h" + namespace webrtc { // Class Config is designed to ease passing a set of options across webrtc code. @@ -86,7 +88,7 @@ class Config { // locks. template static const T& default_value() { - static const T def; + RTC_DEFINE_STATIC_LOCAL(const T, def, ()); return def; } diff --git a/webrtc/overrides/webrtc/base/basictypes.h b/webrtc/overrides/webrtc/base/basictypes.h index c32d8b6502..e75b8c82b5 100644 --- a/webrtc/overrides/webrtc/base/basictypes.h +++ b/webrtc/overrides/webrtc/base/basictypes.h @@ -86,14 +86,15 @@ typedef int socklen_t; #else // !WEBRTC_WIN #define alignof(t) __alignof__(t) #endif // !WEBRTC_WIN -#define RTC_IS_ALIGNED(p, a) (0==(reinterpret_cast(p) & ((a)-1))) +#ifndef ALIGNP #define ALIGNP(p, t) \ (reinterpret_cast(((reinterpret_cast(p) + \ ((t)-1)) & ~((t)-1)))) +#endif +#define RTC_IS_ALIGNED(p, a) (0==(reinterpret_cast(p) & ((a)-1))) -// LIBJINGLE_DEFINE_STATIC_LOCAL() is a libjingle's copy -// of CR_DEFINE_STATIC_LOCAL(). -#define LIBJINGLE_DEFINE_STATIC_LOCAL(type, name, arguments) \ +// RTC_DEFINE_STATIC_LOCAL() is libjingle's copy of CR_DEFINE_STATIC_LOCAL(). +#define RTC_DEFINE_STATIC_LOCAL(type, name, arguments) \ CR_DEFINE_STATIC_LOCAL(type, name, arguments) #endif // OVERRIDES_WEBRTC_BASE_BASICTYPES_H__