| 156 | // Threads |
| 157 | |
| 158 | static int32_t GetThreadId() |
| 159 | { |
| 160 | void* tls_data = (ThreadData*)dmThread::GetTlsValue(g_TlsKey); |
| 161 | if (tls_data == 0) |
| 162 | { |
| 163 | // NOTE: We store thread_id + 1. Otherwise we can't differentiate between thread-id 0 and not initialized |
| 164 | int32_t next_thread_id = dmAtomicIncrement32(&g_ThreadCount) + 1; |
| 165 | tls_data = (void*)((uintptr_t)next_thread_id); |
| 166 | dmThread::SetTlsValue(g_TlsKey, tls_data); |
| 167 | } |
| 168 | |
| 169 | intptr_t thread_id = ((intptr_t)tls_data) - 1; |
| 170 | assert(thread_id >= 0); |
| 171 | return (int32_t)thread_id; |
| 172 | } |
| 173 | |
| 174 | /////////////////////////////////////////////////////////////////////////////////////////////// |
| 175 |
no test coverage detected