Commit 9a84f14
committed
SMultithreadPlus: make POSIX thread ID handling portable (#22)
- thread_id_t is now platform-specific: pthread_t on POSIX, unsigned
long on Win32. Avoids the (void*) cast of pthread_t, which is
undefined behaviour on platforms where pthread_t is an opaque
struct (macOS, musl).
- Add thread_id_equals() which uses pthread_equal() on POSIX and ==
on Win32, so the deadlock check in requestExitAndWait()/join() is
now standard-compliant.
- Drop the thread_id_t(-1) sentinel (which is not expressible for an
opaque pthread_t) and gate the deadlock check on mRunning instead;
the protection against thread-ID recycling is preserved because
mRunning is false while no thread is active.
- Clean up the now-unnecessary (thread_id_t)/(uint64_t) casts.
No external callers depend on the previous void* representation —
thread_id_t and getThreadId() are used only inside SMultithreadPlus.1 parent 8e814ce commit 9a84f14
2 files changed
Lines changed: 37 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
9 | 20 | | |
10 | 21 | | |
| 22 | + | |
| 23 | + | |
11 | 24 | | |
12 | 25 | | |
13 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
134 | 139 | | |
135 | 140 | | |
136 | 141 | | |
| |||
178 | 183 | | |
179 | 184 | | |
180 | 185 | | |
181 | | - | |
| 186 | + | |
182 | 187 | | |
183 | 188 | | |
184 | 189 | | |
| |||
198 | 203 | | |
199 | 204 | | |
200 | 205 | | |
201 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
202 | 212 | | |
203 | 213 | | |
204 | 214 | | |
| |||
210 | 220 | | |
211 | 221 | | |
212 | 222 | | |
213 | | - | |
| 223 | + | |
214 | 224 | | |
215 | 225 | | |
216 | 226 | | |
217 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
218 | 231 | | |
219 | 232 | | |
220 | 233 | | |
| |||
234 | 247 | | |
235 | 248 | | |
236 | 249 | | |
237 | | - | |
238 | 250 | | |
239 | 251 | | |
240 | 252 | | |
| |||
243 | 255 | | |
244 | 256 | | |
245 | 257 | | |
246 | | - | |
247 | | - | |
248 | 258 | | |
249 | 259 | | |
250 | 260 | | |
| |||
298 | 308 | | |
299 | 309 | | |
300 | 310 | | |
301 | | - | |
302 | | - | |
303 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
304 | 314 | | |
305 | 315 | | |
306 | 316 | | |
| |||
323 | 333 | | |
324 | 334 | | |
325 | 335 | | |
326 | | - | |
| 336 | + | |
327 | 337 | | |
328 | 338 | | |
329 | 339 | | |
| |||
348 | 358 | | |
349 | 359 | | |
350 | 360 | | |
351 | | - | |
| 361 | + | |
352 | 362 | | |
353 | 363 | | |
354 | 364 | | |
| |||
0 commit comments