--- parser3/src/main/pa_threads.C 2020/12/11 14:59:36 1.4 +++ parser3/src/main/pa_threads.C 2020/12/15 17:10:37 1.7 @@ -1,46 +1,51 @@ /** @file Parser: simple Mutex realization class. - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2020 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -#include #include "pa_threads.h" -volatile const char * IDENT_PA_THREADS_C="$Id: pa_threads.C,v 1.4 2020/12/11 14:59:36 moko Exp $" IDENT_PA_THREADS_H; +volatile const char * IDENT_PA_THREADS_C="$Id: pa_threads.C,v 1.7 2020/12/15 17:10:37 moko Exp $" IDENT_PA_THREADS_H; Mutex global_mutex; -#ifdef WIN32 - -#include +#ifdef _MSC_VER uint pa_get_thread_id() { return GetCurrentThreadId(); } Mutex::Mutex() : - handle(reinterpret_cast(CreateMutex(NULL, FALSE, 0))) { + handle(CreateMutex(NULL, FALSE, 0)) { } Mutex::~Mutex() { - CloseHandle(reinterpret_cast(handle)); + CloseHandle(handle); } void Mutex::acquire() { - WaitForSingleObject(reinterpret_cast(handle), INFINITE); + WaitForSingleObject(handle, INFINITE); } void Mutex::release() { - ReleaseMutex(reinterpret_cast(handle)); + ReleaseMutex(handle); } #else +#include +#ifdef HAVE_GETTID #include +#endif + uint pa_get_thread_id() { +#ifdef HAVE_GETTID return syscall(__NR_gettid); +#else + return 1; +#endif } Mutex::Mutex() {