diff --git a/modules/audio_processing/include/config.h b/modules/audio_processing/include/config.h index 7615f624cf..338fcea482 100644 --- a/modules/audio_processing/include/config.h +++ b/modules/audio_processing/include/config.h @@ -13,7 +13,6 @@ #include -#include "rtc_base/basictypes.h" #include "rtc_base/constructormagic.h" namespace webrtc { @@ -98,8 +97,8 @@ class Config { // locks. template static const T& default_value() { - RTC_DEFINE_STATIC_LOCAL(const T, def, ()); - return def; + static const T* const def = new T(); + return *def; } typedef std::map OptionMap; diff --git a/rtc_base/basictypes.h b/rtc_base/basictypes.h index 01ba5ef0e3..4430731981 100644 --- a/rtc_base/basictypes.h +++ b/rtc_base/basictypes.h @@ -11,9 +11,6 @@ #ifndef RTC_BASE_BASICTYPES_H_ #define RTC_BASE_BASICTYPES_H_ -#include // for NULL, size_t -#include // for uintptr_t and (u)int_t types. - // Detect compiler is for x86 or x64. #if defined(__x86_64__) || defined(_M_X64) || \ defined(__i386__) || defined(_M_IX86) @@ -49,14 +46,4 @@ typedef int socklen_t; #endif -// The following only works for C++ -#ifdef __cplusplus - -// Use these to declare and define a static local variable that gets leaked so -// that its destructors are not called at exit. -#define RTC_DEFINE_STATIC_LOCAL(type, name, arguments) \ - static type& name = *new type arguments - -#endif // __cplusplus - #endif // RTC_BASE_BASICTYPES_H_ diff --git a/rtc_base/byteorder.h b/rtc_base/byteorder.h index 85f0cc544a..43cfb3694e 100644 --- a/rtc_base/byteorder.h +++ b/rtc_base/byteorder.h @@ -11,6 +11,8 @@ #ifndef RTC_BASE_BYTEORDER_H_ #define RTC_BASE_BYTEORDER_H_ +#include + #if defined(WEBRTC_POSIX) && !defined(__native_client__) #include #endif diff --git a/rtc_base/helpers.cc b/rtc_base/helpers.cc index 9cb9268792..89cf609d1d 100644 --- a/rtc_base/helpers.cc +++ b/rtc_base/helpers.cc @@ -16,7 +16,6 @@ #include #include "rtc_base/base64.h" -#include "rtc_base/basictypes.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" #include "rtc_base/timeutils.h" @@ -85,8 +84,9 @@ static const char kUuidDigit17[4] = {'8', '9', 'a', 'b'}; // This round about way of creating a global RNG is to safe-guard against // indeterminant static initialization order. std::unique_ptr& GetGlobalRng() { - RTC_DEFINE_STATIC_LOCAL(std::unique_ptr, global_rng, - (new SecureRandomGenerator())); + static std::unique_ptr& global_rng + = *new std::unique_ptr(new SecureRandomGenerator()); + return global_rng; } diff --git a/rtc_base/physicalsocketserver.cc b/rtc_base/physicalsocketserver.cc index 636c034e71..22a3882bd4 100644 --- a/rtc_base/physicalsocketserver.cc +++ b/rtc_base/physicalsocketserver.cc @@ -937,8 +937,8 @@ class PosixSignalHandler { // sort of user-defined void * parameter, so they can't access anything that // isn't global.) static PosixSignalHandler* Instance() { - RTC_DEFINE_STATIC_LOCAL(PosixSignalHandler, instance, ()); - return &instance; + static PosixSignalHandler* const instance = new PosixSignalHandler(); + return instance; } // Returns true if the given signal number is set. diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 80e4adc462..50ff4da43d 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -35,8 +35,8 @@ namespace rtc { ThreadManager* ThreadManager::Instance() { - RTC_DEFINE_STATIC_LOCAL(ThreadManager, thread_manager, ()); - return &thread_manager; + static ThreadManager* const thread_manager = new ThreadManager(); + return thread_manager; } ThreadManager::~ThreadManager() {