MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / thread_start

Function thread_start

test/pthread/test_pthread_malloc.c:15–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#define N 6
14
15static void *thread_start(void *arg) {
16 long n = (long)arg;
17 long *mem[N] = {};
18 for (long i = 0; i < N; ++i) {
19 mem[i] = (long*)malloc(sizeof(long));
20 *mem[i] = n+i;
21 }
22 for (long i = 0; i < N; ++i) {
23 long k = *mem[i];
24 if (k != n+i) {
25 emscripten_errf("Memory corrupted! mem[i]: %ld, i: %ld, n: %ld", k, i, n);
26 return (void*)1;
27 }
28
29 assert(*mem[i] == n+i);
30 free(mem[i]);
31 }
32 emscripten_outf("Worker with task number %ld finished", n);
33 return (void*)0;
34}
35
36int main() {
37 pthread_t thr[NUM_THREADS];

Callers

nothing calls this directly

Calls 5

emscripten_errfFunction · 0.85
mallocFunction · 0.70
freeFunction · 0.70
emscripten_outfFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected