X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=6044d0aa0df5777bdc0f89d72ccc6999d5caf662;hp=1f01537ffd2845ca311b509300eddedb5c9f899e;hb=7d5b8fcf7724a66f191cae45d858a1b3d63c2bce;hpb=bc6a6e04a07423433342085397a03af881ebe080 diff --git a/src/thread.cpp b/src/thread.cpp index 1f01537f..6044d0aa 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -33,17 +33,17 @@ namespace { extern "C" { #if defined(_MSC_VER) - DWORD WINAPI start_routine(LPVOID threadID) { + DWORD WINAPI start_routine(LPVOID thread) { - Threads[*(int*)threadID].idle_loop(NULL); + ((Thread*)thread)->idle_loop(NULL); return 0; } #else - void* start_routine(void* threadID) { + void* start_routine(void* thread) { - Threads[*(int*)threadID].idle_loop(NULL); + ((Thread*)thread)->idle_loop(NULL); return NULL; } @@ -173,15 +173,15 @@ void ThreadsManager::init() { threads[i].threadID = i; #if defined(_MSC_VER) - threads[i].handle = CreateThread(NULL, 0, start_routine, (LPVOID)&threads[i].threadID, 0, NULL); + threads[i].handle = CreateThread(NULL, 0, start_routine, (LPVOID)&threads[i], 0, NULL); bool ok = (threads[i].handle != NULL); #else - bool ok = (pthread_create(&threads[i].handle, NULL, start_routine, (void*)&threads[i].threadID) == 0); + bool ok = (pthread_create(&threads[i].handle, NULL, start_routine, (void*)&threads[i]) == 0); #endif if (!ok) { - std::cout << "Failed to create thread number " << i << std::endl; + std::cerr << "Failed to create thread number " << i << std::endl; ::exit(EXIT_FAILURE); } }