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

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

Issue 23717023: Android: Add chrome-specific dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove findbugs issues. 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_thread.h
diff --git a/third_party/crazy_linker/crazy_linker/src/crazy_linker_thread.h b/third_party/crazy_linker/crazy_linker/src/crazy_linker_thread.h
new file mode 100644
index 0000000000000000000000000000000000000000..75eaf2e7ecd678ebac9f855f8cdcbee747834422
--- /dev/null
+++ b/third_party/crazy_linker/crazy_linker/src/crazy_linker_thread.h
@@ -0,0 +1,83 @@
+// 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_THREAD_H
+#define CRAZY_LINKER_THREAD_H
+
+#include <stdarg.h>
+#include <stddef.h>
+
+namespace crazy {
+
+// Per-thread context used during crazy linker operations.
+class ThreadData {
+
+public:
+ ThreadData() {}
+
+ // Init new ThreadData instance.
+ void Init();
+
+ // Return the current error message. This also clears the internal
+ // error message, which means that the next call to this method
+ // will return a pointer to an empty string unless AppendError()
+ // was called.
+ const char* GetError() const {
+ return dlerror_;
+ }
+
+ // Swap the error buffers.
+ void SwapErrorBuffers();
+
+ // Set message string in current dlerror buffer.
+ void SetError(const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ SetErrorArgs(fmt, args);
+ va_end(args);
+ }
+
+ void SetErrorArgs(const char* fmt, va_list args);
+
+ // Append message string to current dlerror buffer.
+ void AppendError(const char* fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+ AppendErrorArgs(fmt, args);
+ va_end(args);
+ }
+
+ void AppendErrorArgs(const char* fmt, va_list args);
+
+private:
+ // Pointer to the current dlerror buffer. This points to one
+ // of the dlerror_buffers[] arrays, swapped on each dlerror()
+ // call.
+ char* dlerror_;
+
+ // Size of each dlerror message buffer size.
+ static const size_t kBufferSize = 512;
+
+ // Two buffers used to store dlerror messages.
+ char dlerror_buffers_[2][kBufferSize];
+};
+
+// Retrieves the ThreadData structure for the current thread.
+// The first time this is called on a given thread, this creates
+// a fresh new object, so this should never return NULL.
+ThreadData* GetThreadData();
+
+// Faster variant that should only be called when GetThreadData() was
+// called at least once on the current thread.
+ThreadData* GetThreadDataFast();
+
+// Set the linker error string for the current thread.
+void SetLinkerErrorString(const char* str);
+
+// Set the formatted linker error for the current thread.
+void SetLinkerError(const char* fmt, ...);
+
+} // namespace crazy;
+
+#endif // CRAZY_LINKER_THREAD_H

Powered by Google App Engine
This is Rietveld 408576698