# endif
# ifdef GC_PTHREADS
if ((code = pthread_create (&t, NULL, thread, NULL)) != 0) {
- printf("Thread creation failed %d\n", code);
+ fprintf(stderr, "Thread creation failed %d\n", code);
return 1;
}
if ((code = pthread_join (t, NULL)) != 0) {
- printf("Thread join failed %d\n", code);
+ fprintf(stderr, "Thread join failed %d\n", code);
return 1;
}
# else
t = CreateThread(NULL, 0, thread, 0, 0, &thread_id);
if (t == NULL) {
- printf("Thread creation failed %d\n", (int)GetLastError());
+ fprintf(stderr, "Thread creation failed %d\n", (int)GetLastError());
return 1;
}
if (WaitForSingleObject(t, INFINITE) != WAIT_OBJECT_0) {
- printf("Thread join failed %d\n", (int)GetLastError());
+ fprintf(stderr, "Thread join failed %d\n", (int)GetLastError());
CloseHandle(t);
return 1;
}
DWORD thread_id;
th = CreateThread(NULL, 0, entry, (LPVOID)my_depth, 0, &thread_id);
if (th == NULL) {
- printf("Thread #%d creation failed: %d\n", thread_num,
+ fprintf(stderr, "Thread #%d creation failed: %d\n", thread_num,
(int)GetLastError());
exit(2);
}
DWORD thread_id;
th[i] = CreateThread(NULL, 0, entry, 0, 0, &thread_id);
if (th[i] == NULL) {
- printf("Thread creation failed: %d\n", (int)GetLastError());
+ fprintf(stderr, "Thread creation failed: %d\n",
+ (int)GetLastError());
exit(1);
}
# endif
}
# else
if (WaitForSingleObject(th[i], INFINITE) != WAIT_OBJECT_0) {
- printf("Failed to join thread: %d\n", (int)GetLastError());
+ fprintf(stderr, "Failed to join thread: %d\n",
+ (int)GetLastError());
CloseHandle(th[i]);
exit(1);
}
code = t[i] != NULL ? 0 : (int)GetLastError();
# endif
if (code != 0) {
- printf("Thread creation failed %d\n", code);
+ fprintf(stderr, "Thread creation failed %d\n", code);
+ exit(2);
}
}
(int)GetLastError();
# endif
if (code != 0) {
- printf("Thread join failed %d\n", code);
+ fprintf(stderr, "Thread join failed %d\n", code);
+ exit(2);
}
}
if (0 == i) return 0;
if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
if (r == NULL) {
- printf("Out of memory\n");
+ fprintf(stderr, "Out of memory\n");
exit(1);
}
r -> x = mktree(i-1);