| 115 | } |
| 116 | |
| 117 | static pid_t GetPid() |
| 118 | { |
| 119 | static __thread pid_t pid = 0; |
| 120 | static __thread pid_t tid = 0; |
| 121 | if( !pid || !tid || pid != getpid() ) |
| 122 | { |
| 123 | pid = getpid(); |
| 124 | #if defined( __APPLE__ ) |
| 125 | tid = syscall( SYS_gettid ); |
| 126 | if( -1 == (long)tid ) |
| 127 | { |
| 128 | tid = pid; |
| 129 | } |
| 130 | #elif defined( __FreeBSD__ ) |
| 131 | syscall(SYS_thr_self, &tid); |
| 132 | if( tid < 0 ) |
| 133 | { |
| 134 | tid = pid; |
| 135 | } |
| 136 | #else |
| 137 | tid = syscall( __NR_gettid ); |
| 138 | #endif |
| 139 | |
| 140 | } |
| 141 | return tid; |
| 142 | |
| 143 | } |
| 144 | /* |
| 145 | static pid_t GetPid() |
| 146 | { |
no outgoing calls
no test coverage detected