| 180 | static void run_os_threads(size_t nthreads, void (*entry)(intptr_t tid)); |
| 181 | |
| 182 | static void test_stress(void) { |
| 183 | uintptr_t r = rand(); |
| 184 | for (int n = 0; n < ITER; n++) { |
| 185 | run_os_threads(THREADS, &stress); |
| 186 | for (int i = 0; i < TRANSFERS; i++) { |
| 187 | if (chance(50, &r) || n + 1 == ITER) { // free all on last run, otherwise free half of the transfers |
| 188 | void* p = atomic_exchange_ptr(&transfer[i], NULL); |
| 189 | free_items(p); |
| 190 | } |
| 191 | } |
| 192 | #ifndef NDEBUG |
| 193 | //mi_collect(false); |
| 194 | //mi_debug_show_arenas(); |
| 195 | #endif |
| 196 | #if !defined(NDEBUG) || defined(MI_TSAN) |
| 197 | if ((n + 1) % 10 == 0) { printf("- iterations left: %3d\n", ITER - (n + 1)); } |
| 198 | #endif |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | #ifndef STRESS |
| 203 | static void leak(intptr_t tid) { |
no test coverage detected