| 1546 | } |
| 1547 | |
| 1548 | static void tl_release(void *raw) { |
| 1549 | tl_state_t *st = (tl_state_t *)raw; |
| 1550 | if (!st || raw == TL_EXITED) { |
| 1551 | return; |
| 1552 | } |
| 1553 | st->busy = true; |
| 1554 | flush_state(st); |
| 1555 | /* Mark the slot before the memory goes: whatever the rest of the thread's |
| 1556 | * teardown allocates or frees must find the marker, neither a freed pointer |
| 1557 | * nor an empty slot that would build a new state. */ |
| 1558 | #ifdef _WIN32 |
| 1559 | (void)TlsSetValue(g_key, TL_EXITED); |
| 1560 | #else |
| 1561 | (void)pthread_setspecific(g_key, TL_EXITED); |
| 1562 | #endif |
| 1563 | atomic_fetch_sub_explicit(&g_layer_threads, 1, memory_order_relaxed); |
| 1564 | vm_put(st, tl_bytes()); |
| 1565 | } |
| 1566 | |
| 1567 | /* ── phase snapshot ─────────────────────────────────────────────────── |
| 1568 | * Live blocks allocated in an earlier phase are RETAINED: the question is |
no test coverage detected