1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
diff --git a/exception.cc b/exception.cc
index 1a6a487..2e84ce8 100644
--- /exception.cc
+++ /exception.cc
@@ -36,29 +36,6 @@
#include "cxxabi.h"
#include <sanitizer/msan_interface.h>
-#pragma weak pthread_key_create
-#pragma weak pthread_setspecific
-#pragma weak pthread_getspecific
-#pragma weak pthread_once
-#ifdef LIBCXXRT_WEAK_LOCKS
-#pragma weak pthread_mutex_lock
-#define pthread_mutex_lock(mtx) do {\
- if (pthread_mutex_lock) pthread_mutex_lock(mtx);\
- } while(0)
-#pragma weak pthread_mutex_unlock
-#define pthread_mutex_unlock(mtx) do {\
- if (pthread_mutex_unlock) pthread_mutex_unlock(mtx);\
- } while(0)
-#pragma weak pthread_cond_signal
-#define pthread_cond_signal(cv) do {\
- if (pthread_cond_signal) pthread_cond_signal(cv);\
- } while(0)
-#pragma weak pthread_cond_wait
-#define pthread_cond_wait(cv, mtx) do {\
- if (pthread_cond_wait) pthread_cond_wait(cv, mtx);\
- } while(0)
-#endif
-
using namespace ABI_NAMESPACE;
/**
@@ -467,31 +444,16 @@ static void thread_cleanup(void* thread_info)
*/
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
-/**
- * We may not be linked against a full pthread implementation. If we're not,
- * then we need to fake the thread-local storage by storing 'thread-local'
- * things in a global.
- */
-static bool fakeTLS;
-/**
- * Thread-local storage for a single-threaded program.
- */
-static __cxa_thread_info singleThreadInfo;
/**
* Initialise eh_key.
*/
static void init_key(void)
{
- if ((0 == pthread_key_create) ||
- (0 == pthread_setspecific) ||
- (0 == pthread_getspecific))
- {
- fakeTLS = true;
- return;
- }
pthread_key_create(&eh_key, thread_cleanup);
pthread_setspecific(eh_key, reinterpret_cast<void *>(0x42));
- fakeTLS = (pthread_getspecific(eh_key) != reinterpret_cast<void *>(0x42));
+ if (pthread_getspecific(eh_key) != reinterpret_cast<void *>(0x42)) {
+ abort();
+ }
pthread_setspecific(eh_key, 0);
}
@@ -505,11 +467,7 @@ static __cxa_thread_info *thread_info()
if (THR_INFO) {
return THR_INFO;
}
- if ((0 == pthread_once) || pthread_once(&once_control, init_key))
- {
- fakeTLS = true;
- }
- if (fakeTLS) { return &singleThreadInfo; }
+ pthread_once(&once_control, init_key);
__cxa_thread_info *info = static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key));
if (0 == info)
{
@@ -536,7 +494,6 @@ static __cxa_thread_info *thread_info_fast()
if (THR_INFO) {
return THR_INFO;
}
- if (fakeTLS) { return &singleThreadInfo; }
return static_cast<__cxa_thread_info*>(pthread_getspecific(eh_key));
}
/**
|