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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 void lockAtomicallyInitializedStaticMutex() { | 96 void lockAtomicallyInitializedStaticMutex() { |
97 DCHECK(atomicallyInitializedStaticMutex); | 97 DCHECK(atomicallyInitializedStaticMutex); |
98 atomicallyInitializedStaticMutex->lock(); | 98 atomicallyInitializedStaticMutex->lock(); |
99 } | 99 } |
100 | 100 |
101 void unlockAtomicallyInitializedStaticMutex() { | 101 void unlockAtomicallyInitializedStaticMutex() { |
102 atomicallyInitializedStaticMutex->unlock(); | 102 atomicallyInitializedStaticMutex->unlock(); |
103 } | 103 } |
104 | 104 |
105 ThreadIdentifier currentThread() { | 105 ThreadIdentifier currentThread() { |
106 // TLS lookup is fast on these platforms. | |
107 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) | |
108 return wtfThreadData().threadId(); | 106 return wtfThreadData().threadId(); |
109 #else | |
110 // TODO(csharrison): For platforms where TLS lookup is slow, use the hack that | |
111 // oilpan uses in ThreadState::current() to check if this is the main thread | |
112 // via stack address. | |
113 return internal::currentThreadSyscall(); | |
114 #endif | |
115 } | 107 } |
116 | 108 |
117 MutexBase::MutexBase(bool recursive) { | 109 MutexBase::MutexBase(bool recursive) { |
118 pthread_mutexattr_t attr; | 110 pthread_mutexattr_t attr; |
119 pthread_mutexattr_init(&attr); | 111 pthread_mutexattr_init(&attr); |
120 pthread_mutexattr_settype( | 112 pthread_mutexattr_settype( |
121 &attr, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL); | 113 &attr, recursive ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL); |
122 | 114 |
123 int result = pthread_mutex_init(&m_mutex.m_internalMutex, &attr); | 115 int result = pthread_mutex_init(&m_mutex.m_internalMutex, &attr); |
124 DCHECK_EQ(result, 0); | 116 DCHECK_EQ(result, 0); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 246 } |
255 | 247 |
256 void willCreateThread() { | 248 void willCreateThread() { |
257 s_threadCreated = true; | 249 s_threadCreated = true; |
258 } | 250 } |
259 #endif | 251 #endif |
260 | 252 |
261 } // namespace WTF | 253 } // namespace WTF |
262 | 254 |
263 #endif // OS(POSIX) | 255 #endif // OS(POSIX) |
OLD | NEW |