Delete macro RTC_DEFINE_STATIC_LOCAL.
Code using the macro change to a plain declaration+init of a local
variable.
Also delete includes of <stdint.h> and <stddef.h> from basictypes.h.
Bug: webrtc:6853
Change-Id: I5ffceb449c1bf8f5badb595d5a343a47b0c6deae
Reviewed-on: https://webrtc-review.googlesource.com/78460
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23377}
diff --git a/modules/audio_processing/include/config.h b/modules/audio_processing/include/config.h
index 7615f62..338fcea 100644
--- a/modules/audio_processing/include/config.h
+++ b/modules/audio_processing/include/config.h
@@ -13,7 +13,6 @@
#include <map>
-#include "rtc_base/basictypes.h"
#include "rtc_base/constructormagic.h"
namespace webrtc {
@@ -98,8 +97,8 @@
// locks.
template<typename T>
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<ConfigOptionID, BaseOption*> OptionMap;
diff --git a/rtc_base/basictypes.h b/rtc_base/basictypes.h
index 01ba5ef..44307319 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 <stddef.h> // for NULL, size_t
-#include <stdint.h> // 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 85f0cc5..43cfb36 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 <stdint.h>
+
#if defined(WEBRTC_POSIX) && !defined(__native_client__)
#include <arpa/inet.h>
#endif
diff --git a/rtc_base/helpers.cc b/rtc_base/helpers.cc
index 9cb9268..89cf609 100644
--- a/rtc_base/helpers.cc
+++ b/rtc_base/helpers.cc
@@ -16,7 +16,6 @@
#include <openssl/rand.h>
#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 @@
// This round about way of creating a global RNG is to safe-guard against
// indeterminant static initialization order.
std::unique_ptr<RandomGenerator>& GetGlobalRng() {
- RTC_DEFINE_STATIC_LOCAL(std::unique_ptr<RandomGenerator>, global_rng,
- (new SecureRandomGenerator()));
+ static std::unique_ptr<RandomGenerator>& global_rng
+ = *new std::unique_ptr<RandomGenerator>(new SecureRandomGenerator());
+
return global_rng;
}
diff --git a/rtc_base/physicalsocketserver.cc b/rtc_base/physicalsocketserver.cc
index 636c034..22a3882 100644
--- a/rtc_base/physicalsocketserver.cc
+++ b/rtc_base/physicalsocketserver.cc
@@ -937,8 +937,8 @@
// 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 80e4adc..50ff4da 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() {