--- parser3/src/main/pa_threads.C 2020/12/11 14:59:36 1.4 +++ parser3/src/main/pa_threads.C 2026/10/29 11:50:58 1.13 @@ -1,46 +1,58 @@ /** @file Parser: simple Mutex realization class. - Copyright (c) 2001-2017 Art. Lebedev Studio (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ -#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.13 2026/10/29 11:50:58 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 +#ifdef HAVE_THR_SELF +#include +#endif + uint pa_get_thread_id() { +#if defined(HAVE_GETTID) return syscall(__NR_gettid); +#elif defined(HAVE_THR_SELF) + long id; + thr_self(&id); + return id; +#else + return getpid(); +#endif } Mutex::Mutex() {