Make Config::default_value leak instead of having an exit-time destructor.
I wanted to use Config::Get in Chromium code, but it triggered the following
warning:
../../third_party/webrtc/common.h:89:20: error: declaration requires an exit-time destructor [-Werror,-Wexit-time-destructors]
static const T def;
^
../../third_party/webrtc/common.h:110:10: note: in instantiation of function template specialization requested here
return default_value<T>();
^
I assume we don't hit this in webrtc because the warning is disabled.
This also switches to the RTC_ prefix from the deprecated LIBJINGLE_.
Needed due to this Chromium CL:
https://codereview.chromium.org/1148843004/
R=andresp@webrtc.org, tommi@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/53459004
Cr-Commit-Position: refs/heads/master@{#9268}
This commit is contained in:
parent
4bf12eafba
commit
469c2c04aa
@ -770,7 +770,7 @@ void SrtpSession::HandleEventThunk(srtp_event_data_t* ev) {
|
||||
}
|
||||
|
||||
std::list<SrtpSession*>* SrtpSession::sessions() {
|
||||
LIBJINGLE_DEFINE_STATIC_LOCAL(std::list<SrtpSession*>, sessions, ());
|
||||
RTC_DEFINE_STATIC_LOCAL(std::list<SrtpSession*>, sessions, ());
|
||||
return &sessions;
|
||||
}
|
||||
|
||||
|
||||
@ -111,14 +111,16 @@ typedef int socklen_t;
|
||||
|
||||
// The following only works for C++
|
||||
#ifdef __cplusplus
|
||||
#ifndef ALIGNP
|
||||
#define ALIGNP(p, t) \
|
||||
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(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
|
||||
|
||||
@ -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<RandomGenerator>& GetGlobalRng() {
|
||||
LIBJINGLE_DEFINE_STATIC_LOCAL(scoped_ptr<RandomGenerator>, global_rng,
|
||||
(new SecureRandomGenerator()));
|
||||
RTC_DEFINE_STATIC_LOCAL(scoped_ptr<RandomGenerator>, global_rng,
|
||||
(new SecureRandomGenerator()));
|
||||
return global_rng;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#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<typename T>
|
||||
static const T& default_value() {
|
||||
static const T def;
|
||||
RTC_DEFINE_STATIC_LOCAL(const T, def, ());
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
@ -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<uintptr_t>(p) & ((a)-1)))
|
||||
#ifndef ALIGNP
|
||||
#define ALIGNP(p, t) \
|
||||
(reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
|
||||
((t)-1)) & ~((t)-1))))
|
||||
#endif
|
||||
#define RTC_IS_ALIGNED(p, a) (0==(reinterpret_cast<uintptr_t>(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__
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user