OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) | 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) |
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void unsafeThreadWasDetached(ThreadIdentifier); | 103 void unsafeThreadWasDetached(ThreadIdentifier); |
104 void threadDidExit(ThreadIdentifier); | 104 void threadDidExit(ThreadIdentifier); |
105 void threadWasJoined(ThreadIdentifier); | 105 void threadWasJoined(ThreadIdentifier); |
106 | 106 |
107 static Mutex& threadMapMutex() | 107 static Mutex& threadMapMutex() |
108 { | 108 { |
109 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); | 109 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); |
110 return mutex; | 110 return mutex; |
111 } | 111 } |
112 | 112 |
113 #if OS(QNX) && CPU(ARM_THUMB2) | |
114 static void enableIEEE754Denormal() | |
115 { | |
116 // Clear the ARM_VFP_FPSCR_FZ flag in FPSCR. | |
117 unsigned fpscr; | |
118 asm volatile("vmrs %0, fpscr" : "=r"(fpscr)); | |
119 fpscr &= ~0x01000000u; | |
120 asm volatile("vmsr fpscr, %0" : : "r"(fpscr)); | |
121 } | |
122 #endif | |
123 | |
124 void initializeThreading() | 113 void initializeThreading() |
125 { | 114 { |
126 if (atomicallyInitializedStaticMutex) | 115 if (atomicallyInitializedStaticMutex) |
127 return; | 116 return; |
128 | 117 |
129 #if OS(QNX) && CPU(ARM_THUMB2) | |
130 enableIEEE754Denormal(); | |
131 #endif | |
132 | |
133 WTF::double_conversion::initialize(); | 118 WTF::double_conversion::initialize(); |
134 // StringImpl::empty() does not construct its static string in a threadsafe
fashion, | 119 // StringImpl::empty() does not construct its static string in a threadsafe
fashion, |
135 // so ensure it has been initialized from here. | 120 // so ensure it has been initialized from here. |
136 StringImpl::empty(); | 121 StringImpl::empty(); |
137 atomicallyInitializedStaticMutex = new Mutex; | 122 atomicallyInitializedStaticMutex = new Mutex; |
138 threadMapMutex(); | 123 threadMapMutex(); |
139 initializeRandomNumberGenerator(); | 124 initializeRandomNumberGenerator(); |
140 ThreadIdentifierData::initializeOnce(); | 125 ThreadIdentifierData::initializeOnce(); |
141 StackStats::initialize(); | 126 StackStats::initialize(); |
142 wtfThreadData(); | 127 wtfThreadData(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 ThreadFunctionInvocation* leakedInvocation = invocation.leakPtr(); | 194 ThreadFunctionInvocation* leakedInvocation = invocation.leakPtr(); |
210 UNUSED_PARAM(leakedInvocation); | 195 UNUSED_PARAM(leakedInvocation); |
211 | 196 |
212 return establishIdentifierForPthreadHandle(threadHandle); | 197 return establishIdentifierForPthreadHandle(threadHandle); |
213 } | 198 } |
214 | 199 |
215 void initializeCurrentThreadInternal(const char* threadName) | 200 void initializeCurrentThreadInternal(const char* threadName) |
216 { | 201 { |
217 #if HAVE(PTHREAD_SETNAME_NP) | 202 #if HAVE(PTHREAD_SETNAME_NP) |
218 pthread_setname_np(threadName); | 203 pthread_setname_np(threadName); |
219 #elif OS(QNX) | |
220 pthread_setname_np(pthread_self(), threadName); | |
221 #else | 204 #else |
222 UNUSED_PARAM(threadName); | 205 UNUSED_PARAM(threadName); |
223 #endif | 206 #endif |
224 | 207 |
225 #if OS(MAC_OS_X) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 | 208 #if OS(MAC_OS_X) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 |
226 // All threads that potentially use APIs above the BSD layer must be registe
red with the Objective-C | 209 // All threads that potentially use APIs above the BSD layer must be registe
red with the Objective-C |
227 // garbage collector in case API implementations use garbage-collected memor
y. | 210 // garbage collector in case API implementations use garbage-collected memor
y. |
228 objc_registerThreadWithCollector(); | 211 objc_registerThreadWithCollector(); |
229 #endif | 212 #endif |
230 | 213 |
231 #if OS(QNX) && CPU(ARM_THUMB2) | |
232 enableIEEE754Denormal(); | |
233 #endif | |
234 | |
235 ThreadIdentifier id = identifierByPthreadHandle(pthread_self()); | 214 ThreadIdentifier id = identifierByPthreadHandle(pthread_self()); |
236 ASSERT(id); | 215 ASSERT(id); |
237 ThreadIdentifierData::initialize(id); | 216 ThreadIdentifierData::initialize(id); |
238 } | 217 } |
239 | 218 |
240 int waitForThreadCompletion(ThreadIdentifier threadID) | 219 int waitForThreadCompletion(ThreadIdentifier threadID) |
241 { | 220 { |
242 pthread_t pthreadHandle; | 221 pthread_t pthreadHandle; |
243 ASSERT(threadID); | 222 ASSERT(threadID); |
244 | 223 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 386 |
408 void ThreadCondition::broadcast() | 387 void ThreadCondition::broadcast() |
409 { | 388 { |
410 int result = pthread_cond_broadcast(&m_condition); | 389 int result = pthread_cond_broadcast(&m_condition); |
411 ASSERT_UNUSED(result, !result); | 390 ASSERT_UNUSED(result, !result); |
412 } | 391 } |
413 | 392 |
414 } // namespace WTF | 393 } // namespace WTF |
415 | 394 |
416 #endif // USE(PTHREADS) | 395 #endif // USE(PTHREADS) |
OLD | NEW |