From 03d6b086df1e2571fd2b36d6a989f8c51becb6bc Mon Sep 17 00:00:00 2001 From: ehmaldonado Date: Fri, 25 Nov 2016 06:47:10 -0800 Subject: [PATCH] Get rid of webrtc/base/latebindingsymboltable* It is blocking the chromium roll and they don't seem to be used. R=phoglund@webrtc.org, kjellander@webrtc.org, henrika@webrtc.org BUG=webrtc:6775, webrtc:6739 NOTRY=True Review-Url: https://codereview.webrtc.org/2534593002 Cr-Commit-Position: refs/heads/master@{#15246} --- webrtc/BUILD.gn | 4 - webrtc/base/BUILD.gn | 7 - webrtc/base/latebindingsymboltable.cc | 156 ------------------ webrtc/base/latebindingsymboltable.cc.def | 69 -------- webrtc/base/latebindingsymboltable.h | 70 -------- webrtc/base/latebindingsymboltable.h.def | 83 ---------- .../base/latebindingsymboltable_unittest.cc | 56 ------- 7 files changed, 445 deletions(-) delete mode 100644 webrtc/base/latebindingsymboltable.cc delete mode 100644 webrtc/base/latebindingsymboltable.cc.def delete mode 100644 webrtc/base/latebindingsymboltable.h delete mode 100644 webrtc/base/latebindingsymboltable.h.def delete mode 100644 webrtc/base/latebindingsymboltable_unittest.cc diff --git a/webrtc/BUILD.gn b/webrtc/BUILD.gn index c91792083e..76f51e59b0 100644 --- a/webrtc/BUILD.gn +++ b/webrtc/BUILD.gn @@ -467,10 +467,6 @@ if (rtc_include_tests) { "p2p/stunprober/stunprober_unittest.cc", ] - if (is_linux) { - sources += [ "base/latebindingsymboltable_unittest.cc" ] - } - if (is_win) { sources += [ "base/win32_unittest.cc", diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index 71f9ec45e4..7ff05d2bd9 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -564,13 +564,6 @@ rtc_static_library("rtc_base") { "window.h", ] - if (is_posix) { - sources += [ - "latebindingsymboltable.cc", - "latebindingsymboltable.h", - ] - } - if (is_win) { sources += [ "diskcache_win32.cc", diff --git a/webrtc/base/latebindingsymboltable.cc b/webrtc/base/latebindingsymboltable.cc deleted file mode 100644 index 030f7208c2..0000000000 --- a/webrtc/base/latebindingsymboltable.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2004 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/base/latebindingsymboltable.h" - -#if defined(WEBRTC_POSIX) -#include -#endif - -#include "webrtc/base/logging.h" - -namespace rtc { - -#if defined(WEBRTC_POSIX) -static const DllHandle kInvalidDllHandle = NULL; -#else -#error Not implemented -#endif - -static const char *GetDllError() { -#if defined(WEBRTC_POSIX) - const char *err = dlerror(); - if (err) { - return err; - } else { - return "No error"; - } -#else -#error Not implemented -#endif -} - -static bool LoadSymbol(DllHandle handle, - const char *symbol_name, - void **symbol) { -#if defined(WEBRTC_POSIX) - *symbol = dlsym(handle, symbol_name); - const char *err = dlerror(); - if (err) { - LOG(LS_ERROR) << "Error loading symbol " << symbol_name << ": " << err; - return false; - } else if (!*symbol) { - // ELF allows for symbols to be NULL, but that should never happen for our - // usage. - LOG(LS_ERROR) << "Symbol " << symbol_name << " is NULL"; - return false; - } - return true; -#else -#error Not implemented -#endif -} - -LateBindingSymbolTable::LateBindingSymbolTable(const TableInfo *info, - void **table) - : info_(info), - table_(table), - handle_(kInvalidDllHandle), - undefined_symbols_(false) { - ClearSymbols(); -} - -LateBindingSymbolTable::~LateBindingSymbolTable() { - Unload(); -} - -bool LateBindingSymbolTable::IsLoaded() const { - return handle_ != kInvalidDllHandle; -} - -bool LateBindingSymbolTable::Load() { - ASSERT(info_->dll_name != NULL); - return LoadFromPath(info_->dll_name); -} - -bool LateBindingSymbolTable::LoadFromPath(const char *dll_path) { - if (IsLoaded()) { - return true; - } - if (undefined_symbols_) { - // We do not attempt to load again because repeated attempts are not - // likely to succeed and DLL loading is costly. - LOG(LS_ERROR) << "We know there are undefined symbols"; - return false; - } - -#if defined(WEBRTC_POSIX) - handle_ = dlopen(dll_path, - // RTLD_NOW front-loads symbol resolution so that errors are - // caught early instead of causing a process abort later. - // RTLD_LOCAL prevents other modules from automatically - // seeing symbol definitions in the newly-loaded tree. This - // is necessary for same-named symbols in different ABI - // versions of the same library to not explode. - RTLD_NOW|RTLD_LOCAL -#if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) && defined(RTLD_DEEPBIND) - // RTLD_DEEPBIND makes symbol dependencies in the - // newly-loaded tree prefer to resolve to definitions within - // that tree (the default on OS X). This is necessary for - // same-named symbols in different ABI versions of the same - // library to not explode. - |RTLD_DEEPBIND -#endif - ); // NOLINT -#else -#error Not implemented -#endif - - if (handle_ == kInvalidDllHandle) { - LOG(LS_WARNING) << "Can't load " << dll_path << ": " - << GetDllError(); - return false; - } -#if defined(WEBRTC_POSIX) - // Clear any old errors. - dlerror(); -#endif - for (int i = 0; i < info_->num_symbols; ++i) { - if (!LoadSymbol(handle_, info_->symbol_names[i], &table_[i])) { - undefined_symbols_ = true; - Unload(); - return false; - } - } - return true; -} - -void LateBindingSymbolTable::Unload() { - if (!IsLoaded()) { - return; - } - -#if defined(WEBRTC_POSIX) - if (dlclose(handle_) != 0) { - LOG(LS_ERROR) << GetDllError(); - } -#else -#error Not implemented -#endif - - handle_ = kInvalidDllHandle; - ClearSymbols(); -} - -void LateBindingSymbolTable::ClearSymbols() { - memset(table_, 0, sizeof(void *) * info_->num_symbols); -} - -} // namespace rtc diff --git a/webrtc/base/latebindingsymboltable.cc.def b/webrtc/base/latebindingsymboltable.cc.def deleted file mode 100644 index 6ddb2ae629..0000000000 --- a/webrtc/base/latebindingsymboltable.cc.def +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2012 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This file is a supermacro -// (see http://wanderinghorse.net/computing/papers/supermacros_cpp.html) to -// expand a definition of a late-binding symbol table class. -// -// Arguments: -// LATE_BINDING_SYMBOL_TABLE_CLASS_NAME: Name of the class to generate. -// LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST: List of symbols to load from the DLL, -// as an X-Macro list (see http://www.drdobbs.com/blogs/cpp/228700289). -// LATE_BINDING_SYMBOL_TABLE_DLL_NAME: String literal for the DLL file name to -// load. -// -// From a .cc file, include the header file containing your call to the .h.def -// supermacro, and then call this supermacro (optionally from inside the -// namespace for the class to generate, if any). Example: -// -// #include "myclassname.h" -// -// namespace foo { -// -// #define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME MY_CLASS_NAME -// #define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST MY_SYMBOLS_LIST -// #define LATE_BINDING_SYMBOL_TABLE_DLL_NAME "libdll.so.n" -// #include "webrtc/base/latebindingsymboltable.cc.def" -// -// } - -#ifndef LATE_BINDING_SYMBOL_TABLE_CLASS_NAME -#error You must define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME -#endif - -#ifndef LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST -#error You must define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST -#endif - -#ifndef LATE_BINDING_SYMBOL_TABLE_DLL_NAME -#error You must define LATE_BINDING_SYMBOL_TABLE_DLL_NAME -#endif - -#define X(sym) #sym, -const char* const LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::kSymbolNames[] = { - LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST -}; -#undef X - -const ::rtc::LateBindingSymbolTable::TableInfo - LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::kTableInfo = { - LATE_BINDING_SYMBOL_TABLE_DLL_NAME, - SYMBOL_TABLE_SIZE, - LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::kSymbolNames -}; - -LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::LATE_BINDING_SYMBOL_TABLE_CLASS_NAME() - : ::rtc::LateBindingSymbolTable(&kTableInfo, table_) {} - -LATE_BINDING_SYMBOL_TABLE_CLASS_NAME::~LATE_BINDING_SYMBOL_TABLE_CLASS_NAME() {} - -#undef LATE_BINDING_SYMBOL_TABLE_CLASS_NAME -#undef LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST -#undef LATE_BINDING_SYMBOL_TABLE_DLL_NAME diff --git a/webrtc/base/latebindingsymboltable.h b/webrtc/base/latebindingsymboltable.h deleted file mode 100644 index 794a4ab5a8..0000000000 --- a/webrtc/base/latebindingsymboltable.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2004 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_BASE_LATEBINDINGSYMBOLTABLE_H_ -#define WEBRTC_BASE_LATEBINDINGSYMBOLTABLE_H_ - -#include - -#include "webrtc/base/common.h" -#include "webrtc/base/constructormagic.h" - -namespace rtc { - -#if defined(WEBRTC_POSIX) -typedef void *DllHandle; -#else -#error Not implemented for this platform -#endif - -// This is the base class for "symbol table" classes to simplify the dynamic -// loading of symbols from DLLs. Currently the implementation only supports -// Linux and OS X, and pure C symbols (or extern "C" symbols that wrap C++ -// functions). Sub-classes for specific DLLs are generated via the "supermacro" -// files latebindingsymboltable.h.def and latebindingsymboltable.cc.def. See -// talk/sound/pulseaudiosymboltable.(h|cc) for an example. -class LateBindingSymbolTable { - public: - struct TableInfo { - const char *dll_name; - int num_symbols; - // Array of size num_symbols. - const char *const *symbol_names; - }; - - LateBindingSymbolTable(const TableInfo *info, void **table); - ~LateBindingSymbolTable(); - - bool IsLoaded() const; - // Loads the DLL and the symbol table. Returns true iff the DLL and symbol - // table loaded successfully. - bool Load(); - // Like load, but allows overriding the dll path for when the dll path is - // dynamic. - bool LoadFromPath(const char *dll_path); - void Unload(); - - // Gets the raw OS handle to the DLL. Be careful what you do with it. - DllHandle GetDllHandle() const { return handle_; } - - private: - void ClearSymbols(); - - const TableInfo *info_; - void **table_; - DllHandle handle_; - bool undefined_symbols_; - - RTC_DISALLOW_COPY_AND_ASSIGN(LateBindingSymbolTable); -}; - -} // namespace rtc - -#endif // WEBRTC_BASE_LATEBINDINGSYMBOLTABLE_H_ diff --git a/webrtc/base/latebindingsymboltable.h.def b/webrtc/base/latebindingsymboltable.h.def deleted file mode 100644 index bc6396b1f0..0000000000 --- a/webrtc/base/latebindingsymboltable.h.def +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2012 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This file is a supermacro -// (see http://wanderinghorse.net/computing/papers/supermacros_cpp.html) to -// expand a declaration of a late-binding symbol table class. -// -// Arguments: -// LATE_BINDING_SYMBOL_TABLE_CLASS_NAME: Name of the class to generate. -// LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST: List of symbols to load from the DLL, -// as an X-Macro list (see http://www.drdobbs.com/blogs/cpp/228700289). -// -// From a .h file, include the header(s) for the DLL to late-bind and the -// latebindingsymboltable.h header, and then call this supermacro (optionally -// from inside the namespace for the class to generate, if any). Example: -// -// #include -// -// #include "webrtc/base/latebindingsymboltable.h" -// -// namespace foo { -// -// #define MY_CLASS_NAME DesiredClassName -// #define MY_SYMBOLS_LIST X(acos) X(sin) X(tan) -// -// #define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME MY_CLASS_NAME -// #define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST MY_SYMBOLS_LIST -// #include "webrtc/base/latebindingsymboltable.h.def" -// -// } - -#ifndef WEBRTC_BASE_LATEBINDINGSYMBOLTABLE_H_ -#error You must first include latebindingsymboltable.h -#endif - -#ifndef LATE_BINDING_SYMBOL_TABLE_CLASS_NAME -#error You must define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME -#endif - -#ifndef LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST -#error You must define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST -#endif - -class LATE_BINDING_SYMBOL_TABLE_CLASS_NAME : - public ::rtc::LateBindingSymbolTable { - public: - LATE_BINDING_SYMBOL_TABLE_CLASS_NAME(); - ~LATE_BINDING_SYMBOL_TABLE_CLASS_NAME(); - -#define X(sym) \ - typeof(&::sym) sym() const { \ - ASSERT(::rtc::LateBindingSymbolTable::IsLoaded()); \ - return reinterpret_cast(table_[SYMBOL_TABLE_INDEX_##sym]); \ - } -LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST -#undef X - - private: - enum { -#define X(sym) \ - SYMBOL_TABLE_INDEX_##sym, -LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST -#undef X - SYMBOL_TABLE_SIZE - }; - - static const ::rtc::LateBindingSymbolTable::TableInfo kTableInfo; - static const char *const kSymbolNames[]; - - void *table_[SYMBOL_TABLE_SIZE]; - - RTC_DISALLOW_COPY_AND_ASSIGN(LATE_BINDING_SYMBOL_TABLE_CLASS_NAME); -}; - -#undef LATE_BINDING_SYMBOL_TABLE_CLASS_NAME -#undef LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST diff --git a/webrtc/base/latebindingsymboltable_unittest.cc b/webrtc/base/latebindingsymboltable_unittest.cc deleted file mode 100644 index 0079f20342..0000000000 --- a/webrtc/base/latebindingsymboltable_unittest.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2010 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) -#include -#endif - -#include "webrtc/base/gunit.h" -#include "webrtc/base/latebindingsymboltable.h" - -namespace rtc { - -#if defined(WEBRTC_LINUX) && !defined(WEBRTC_ANDROID) - -#define LIBM_SYMBOLS_CLASS_NAME LibmTestSymbolTable -#define LIBM_SYMBOLS_LIST \ - X(acosf) \ - X(sinf) \ - X(tanf) - - -#define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBM_SYMBOLS_CLASS_NAME -#define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBM_SYMBOLS_LIST -#include "webrtc/base/latebindingsymboltable.h.def" - -#define LATE_BINDING_SYMBOL_TABLE_CLASS_NAME LIBM_SYMBOLS_CLASS_NAME -#define LATE_BINDING_SYMBOL_TABLE_SYMBOLS_LIST LIBM_SYMBOLS_LIST -#define LATE_BINDING_SYMBOL_TABLE_DLL_NAME "libm.so.6" -#include "webrtc/base/latebindingsymboltable.cc.def" - -TEST(LateBindingSymbolTable, libm) { - LibmTestSymbolTable table; - EXPECT_FALSE(table.IsLoaded()); - ASSERT_TRUE(table.Load()); - EXPECT_TRUE(table.IsLoaded()); - EXPECT_EQ(table.acosf()(0.5f), acosf(0.5f)); - EXPECT_EQ(table.sinf()(0.5f), sinf(0.5f)); - EXPECT_EQ(table.tanf()(0.5f), tanf(0.5f)); - // It would be nice to check that the addresses are the same, but the nature - // of dynamic linking and relocation makes them actually be different. - table.Unload(); - EXPECT_FALSE(table.IsLoaded()); -} - -#else -#error Not implemented -#endif - -} // namespace rtc