| 284 | } |
| 285 | |
| 286 | static void run_os_threads(size_t nthreads, void (*fun)(intptr_t)) { |
| 287 | thread_entry_fun = fun; |
| 288 | DWORD* tids = (DWORD*)custom_calloc(nthreads,sizeof(DWORD)); |
| 289 | HANDLE* thandles = (HANDLE*)custom_calloc(nthreads,sizeof(HANDLE)); |
| 290 | for (uintptr_t i = 0; i < nthreads; i++) { |
| 291 | thandles[i] = CreateThread(0, 8*1024, &thread_entry, (void*)(i), 0, &tids[i]); |
| 292 | } |
| 293 | for (size_t i = 0; i < nthreads; i++) { |
| 294 | WaitForSingleObject(thandles[i], INFINITE); |
| 295 | } |
| 296 | for (size_t i = 0; i < nthreads; i++) { |
| 297 | CloseHandle(thandles[i]); |
| 298 | } |
| 299 | custom_free(tids); |
| 300 | custom_free(thandles); |
| 301 | } |
| 302 | |
| 303 | static void* atomic_exchange_ptr(volatile void** p, void* newval) { |
| 304 | #if (INTPTR_MAX == INT32_MAX) |
no outgoing calls
no test coverage detected