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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CRAZY_LINKER_THREAD_H
6 #define CRAZY_LINKER_THREAD_H
7
8 #include <stdarg.h>
9 #include <stddef.h>
10
11 namespace crazy {
12
13 // Per-thread context used during crazy linker operations.
14 class ThreadData {
15
16 public:
17 ThreadData() {}
18
19 // Init new ThreadData instance.
20 void Init();
21
22 // Return the current error message. This also clears the internal
23 // error message, which means that the next call to this method
24 // will return a pointer to an empty string unless AppendError()
25 // was called.
26 const char* GetError() const {
27 return dlerror_;
28 }
29
30 // Swap the error buffers.
31 void SwapErrorBuffers();
32
33 // Set message string in current dlerror buffer.
34 void SetError(const char* fmt, ...) {
35 va_list args;
36 va_start(args, fmt);
37 SetErrorArgs(fmt, args);
38 va_end(args);
39 }
40
41 void SetErrorArgs(const char* fmt, va_list args);
42
43 // Append message string to current dlerror buffer.
44 void AppendError(const char* fmt, ...) {
45 va_list args;
46 va_start(args, fmt);
47 AppendErrorArgs(fmt, args);
48 va_end(args);
49 }
50
51 void AppendErrorArgs(const char* fmt, va_list args);
52
53 private:
54 // Pointer to the current dlerror buffer. This points to one
55 // of the dlerror_buffers[] arrays, swapped on each dlerror()
56 // call.
57 char* dlerror_;
58
59 // Size of each dlerror message buffer size.
60 static const size_t kBufferSize = 512;
61
62 // Two buffers used to store dlerror messages.
63 char dlerror_buffers_[2][kBufferSize];
64 };
65
66 // Retrieves the ThreadData structure for the current thread.
67 // The first time this is called on a given thread, this creates
68 // a fresh new object, so this should never return NULL.
69 ThreadData* GetThreadData();
70
71 // Faster variant that should only be called when GetThreadData() was
72 // called at least once on the current thread.
73 ThreadData* GetThreadDataFast();
74
75 // Set the linker error string for the current thread.
76 void SetLinkerErrorString(const char* str);
77
78 // Set the formatted linker error for the current thread.
79 void SetLinkerError(const char* fmt, ...);
80
81 } // namespace crazy;
82
83 #endif // CRAZY_LINKER_THREAD_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698