| 165 | } |
| 166 | |
| 167 | extern "C" pid_t gettid() |
| 168 | { |
| 169 | static thread_local int pidCache = -1; |
| 170 | #ifdef __linux__ |
| 171 | if (pidCache == -1) |
| 172 | pidCache = syscall(SYS_gettid); |
| 173 | #else |
| 174 | if (pidCache == -1) { |
| 175 | uint64_t tidT; |
| 176 | #ifdef __FreeBSD__ |
| 177 | // Check https://github.com/ClickHouse/ClickHouse/commit/8d51824ddcb604b6f179a0216f0d32ba5612bd2e |
| 178 | tidT = pthread_getthreadid_np(); |
| 179 | #else |
| 180 | pthread_threadid_np(nullptr, &tidT); |
| 181 | #endif |
| 182 | serverAssert(tidT < UINT_MAX); |
| 183 | pidCache = (int)tidT; |
| 184 | } |
| 185 | #endif |
| 186 | return pidCache; |
| 187 | } |
| 188 | |
| 189 | void printTrace() |
| 190 | { |
no outgoing calls
no test coverage detected