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}
This commit is contained in:
Niels Möller 2018-05-24 08:54:25 +02:00 committed by Commit Bot
parent 9d4e840617
commit 14682a3c5f
6 changed files with 11 additions and 23 deletions

View File

@ -13,7 +13,6 @@
#include <map>
#include "rtc_base/basictypes.h"
#include "rtc_base/constructormagic.h"
namespace webrtc {
@ -98,8 +97,8 @@ class Config {
// 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;

View File

@ -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_

View File

@ -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

View File

@ -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 @@ 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<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;
}

View File

@ -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.

View File

@ -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() {