Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1556)

Unified Diff: third_party/crazy_linker/crazy_linker/src/crazy_linker_globals.h

Issue 23542017: This patch adds a new third-party library that implements an ELF dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor update Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/crazy_linker/crazy_linker/src/crazy_linker_globals.h
diff --git a/third_party/crazy_linker/crazy_linker/src/crazy_linker_globals.h b/third_party/crazy_linker/crazy_linker/src/crazy_linker_globals.h
new file mode 100644
index 0000000000000000000000000000000000000000..43dfe8738fa03e54f5604ef7d03823d72ff84446
--- /dev/null
+++ b/third_party/crazy_linker/crazy_linker/src/crazy_linker_globals.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CRAZY_LINKER_GLOBALS_H
+#define CRAZY_LINKER_GLOBALS_H
+
+#include <pthread.h>
+
+#include "crazy_linker_library_list.h"
+#include "crazy_linker_rdebug.h"
+#include "crazy_linker_search_path_list.h"
+#include "crazy_linker_util.h"
+
+// All crazy linker globals are declared in this header.
+
+namespace crazy {
+
+class Globals {
+ public:
+ Globals();
+ ~Globals();
+
+ void Lock() {
+ pthread_mutex_lock(&lock_);
+ }
+
+ void Unlock() {
+ pthread_mutex_unlock(&lock_);
+ }
+
+ static Globals* Get();
+
+ static LibraryList* GetLibraries() {
+ return &Get()->libraries_;
+ }
+
+ static SearchPathList* GetSearchPaths() {
+ return &Get()->search_paths_;
+ }
+
+ static RDebug* GetRDebug() {
+ return &Get()->rdebug_;
+ }
+
+private:
+ pthread_mutex_t lock_;
+ LibraryList libraries_;
+ SearchPathList search_paths_;
+ RDebug rdebug_;
+};
+
+// Helper class to access the globals with scoped locking.
+class ScopedGlobalLock {
+ public:
+ ScopedGlobalLock() {
+ Globals::Get()->Lock();
+ }
+
+ ~ScopedGlobalLock() {
+ Globals::Get()->Unlock();
+ }
+};
+
+} // namespace crazy
+
+#endif // CRAZY_LINKER_GLOBALS_H

Powered by Google App Engine
This is Rietveld 408576698