From edd526d94bba1de343ff90b4bc5c36a8e44cdec9 Mon Sep 17 00:00:00 2001 From: EZ4Stephen Date: Tue, 2 Dec 2025 20:24:24 +0400 Subject: [PATCH 1/8] Adjust pthread include, add || defined(__PTW32_VERSION) Made a new define: OTHER1 , in my config, to not conflict with John E's files. Keeps his build working, while adjusting to mine. Additionally, vcpkg's pthread includes _ptw32.h, which defines __PTW32_VERSION'. --- libs/pbd/cpus.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/pbd/cpus.cc b/libs/pbd/cpus.cc index d43591ce30..b55e1f4874 100644 --- a/libs/pbd/cpus.cc +++ b/libs/pbd/cpus.cc @@ -36,7 +36,11 @@ #include "pbd/cpus.h" #if defined(COMPILER_MSVC) && !defined(PTW32_VERSION) +#ifndef OTHER1 #include // Gets us 'PTW32_VERSION' +#else +#include //Gets us '__PTW32_VERSION' +#endif #endif int32_t @@ -69,7 +73,7 @@ PBD::hardware_concurrency() return c; } } -#if defined(PTW32_VERSION) || defined(__hpux) +#if defined(PTW32_VERSION) || defined(__hpux) || defined(__PTW32_VERSION) return pthread_num_processors_np(); #elif defined(__APPLE__) int count; From cae50f5de6b7737852ae3fdf3fd5adffb2346bcc Mon Sep 17 00:00:00 2001 From: EZ4Stephen Date: Tue, 2 Dec 2025 20:31:01 +0400 Subject: [PATCH 2/8] Add MSVC specific include for io.h Fixes the following errors when building: read': identifier not found (Originally lines 562 and 572, now 566 and 576) 'close': identifier not found (Originally line 574, now line 578) --- libs/pbd/file_archive.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/pbd/file_archive.cc b/libs/pbd/file_archive.cc index f26c7a26f1..e40a8146fc 100644 --- a/libs/pbd/file_archive.cc +++ b/libs/pbd/file_archive.cc @@ -27,6 +27,10 @@ #include #include +#ifdef COMPILER_MSVC +#include +#endif + #include #include "pbd/gstdio_compat.h" #include From 6cb0676e4c2df3b5e5fea34048b4b54e2f6f10f6 Mon Sep 17 00:00:00 2001 From: EZ4Stephen Date: Tue, 2 Dec 2025 20:44:21 +0400 Subject: [PATCH 3/8] Add conditional include for ardourext/misc.h Segregate the inclusion of ardourext/misc.h in file_utils.cc --- libs/pbd/file_utils.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc index 232c29486f..2a03604b59 100644 --- a/libs/pbd/file_utils.cc +++ b/libs/pbd/file_utils.cc @@ -59,8 +59,9 @@ /* close(), read(), write() */ #ifdef COMPILER_MSVC #include // Microsoft's nearest equivalent to +#ifndef OTHER1 #include -#else +#endif #endif #include "pbd/compose.h" From 8d75f339b2e7a84447001a2f8389f2959a697798 Mon Sep 17 00:00:00 2001 From: EZ4Stephen Date: Tue, 2 Dec 2025 21:04:24 +0400 Subject: [PATCH 4/8] Change CreateProcess to CreateProcessA (Windows only) Fixes the following error: 'BOOL CreateProcessW(LPCWSTR,LPWSTR,LPSECURITY_ATTRIBUTES,LPSECURITY_ATTRIBUTES,BOOL,DWORD,LPVOID,LPCWSTR,LPSTARTUPINFOW,LPPROCESS_INFORMATION)': cannot convert argument 2 from 'char *' to 'LPWSTR' --- libs/pbd/system_exec.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc index cc514a01d2..6a22bc326d 100644 --- a/libs/pbd/system_exec.cc +++ b/libs/pbd/system_exec.cc @@ -492,7 +492,7 @@ SystemExec::start (StdErrMode stderr_mode, const char * /*vfork_exec_wrapper*/) stdinP[0], stdoutP[1], stderrP[1] }; - success = CreateProcess(0, w_args, + success = CreateProcessA(0, w_args, 0, 0, /* bInheritHandles = */ TRUE, (CREATE_NO_WINDOW&0) | CREATE_UNICODE_ENVIRONMENT | (0&CREATE_NEW_CONSOLE), /*env = */ 0, From 099f2f4c86ed176e69c2ed19c98bb0582abe8e5f Mon Sep 17 00:00:00 2001 From: EZ4Stephen Date: Tue, 2 Dec 2025 21:07:28 +0400 Subject: [PATCH 5/8] Fix conditional compilation for OTHER1 definition Segregate inclusion of ardourext/misc.h --- libs/pbd/pbd/undo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h index 5d93d451ac..1b7b0a7b26 100644 --- a/libs/pbd/pbd/undo.h +++ b/libs/pbd/pbd/undo.h @@ -31,7 +31,7 @@ #ifndef COMPILER_MSVC #include -#else +#elif !defined(OTHER1) #include #endif From bda088c2a8f53f209a23e03b1860d1d30464781a Mon Sep 17 00:00:00 2001 From: EZ4Stephen Date: Tue, 2 Dec 2025 21:17:01 +0400 Subject: [PATCH 6/8] Change an #ifdef COMPILER_MSVC More segregation of the inclusion of ardourext/misc.h. --- libs/pbd/pbd/abstract_ui.inc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pbd/pbd/abstract_ui.inc.cc b/libs/pbd/pbd/abstract_ui.inc.cc index dbc0061060..33fa572a4b 100644 --- a/libs/pbd/pbd/abstract_ui.inc.cc +++ b/libs/pbd/pbd/abstract_ui.inc.cc @@ -31,7 +31,7 @@ #include "pbd/i18n.h" -#ifdef COMPILER_MSVC +#if defined(COMPILER_MSVC) && !defined(OTHER1) #include // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be // searched and sorted. Thus, when instantiating the container, MSVC complains // if the type of object being contained has no appropriate comparison operators From 6efe8ceeff4ff0a24dce194f0d9b0876ade84332 Mon Sep 17 00:00:00 2001 From: EZ4Stephen Date: Tue, 2 Dec 2025 21:45:34 +0400 Subject: [PATCH 7/8] Update conditional include for pthread.h Further exclusion of the use of ardourext/pthread.h --- libs/pbd/pbd/debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/pbd/pbd/debug.h b/libs/pbd/pbd/debug.h index 7efea83d11..146adcb26e 100644 --- a/libs/pbd/pbd/debug.h +++ b/libs/pbd/pbd/debug.h @@ -30,7 +30,7 @@ #include "pbd/timing.h" /* check for PTW32_VERSION */ -#ifdef COMPILER_MSVC +#if defined(COMPILER_MSVC) && !defined(OTHER1) #include #else #include From ffbe87961ee7cbb9fa4cdbac63a9d1dde8a9968b Mon Sep 17 00:00:00 2001 From: EZ4Stephen Date: Tue, 2 Dec 2025 23:03:12 +0400 Subject: [PATCH 8/8] Replace DECLARE_DEFAULT_COMPARISONS in pthread_utils, revert some changes from about 3 weeks ago 1. Replaced DECLARE_DEFAULT_COMPARISONS (pthread_t) with 5 ddifferent LIBPBD_API inline bool operators. 2. Revert some if (pthread_equal (t.first, pthread_self ()) != 0) { to if (pthread_equal (t.first, pthread_self ())) { (along with one other example). --- libs/pbd/pthread_utils.cc | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index d2d24f38c4..81ed0311f6 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -38,11 +38,21 @@ #include "pbd/pthread_utils.h" #ifdef COMPILER_MSVC -DECLARE_DEFAULT_COMPARISONS (pthread_t) // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be - // searched and sorted. Thus, when instantiating the container, MSVC complains - // if the type of object being contained has no appropriate comparison operators - // defined (specifically, if operators '<' and '==' are undefined). This seems - // to be the case with ptw32 'pthread_t' which is a simple struct. +LIBPBD_API inline bool operator<(const pthread_t& lhs, const pthread_t& rhs) { + return lhs.p != rhs.p ? lhs.p < rhs.p : lhs.x < rhs.x; +} +LIBPBD_API inline bool operator==(const pthread_t& lhs, const pthread_t& rhs) { + return lhs.p == rhs.p && lhs.x == rhs.x; +} +LIBPBD_API inline bool operator!=(const pthread_t& lhs, const pthread_t& rhs) { + return !(lhs == rhs); +} +LIBPBD_API inline bool operator==(const pthread_t& lhs, int rhs) { + return !rhs && !lhs.p; +} +LIBPBD_API inline bool operator!=(const pthread_t& lhs, int rhs) { + return rhs || lhs.p; +} #define pthread_gethandle pthread_getw32threadhandle_np #endif @@ -194,7 +204,7 @@ fake_thread_start (void* arg) pthread_mutex_lock (&thread_map_lock); for (auto const& t : all_threads) { - if (pthread_equal (t.first, pthread_self ()) != 0) { + if (pthread_equal (t.first, pthread_self ())) { DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second)); all_threads.erase (t.first); break; @@ -262,7 +272,7 @@ pthread_kill_all (int signum) { pthread_mutex_lock (&thread_map_lock); for (auto const& t : all_threads) { - if (pthread_equal (t.first, pthread_self ()) != 0) { + if (pthread_equal (t.first, pthread_self ())) { continue; } DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Kill: '%1'\n", t.second)); @@ -277,7 +287,7 @@ pthread_cancel_all () { pthread_mutex_lock (&thread_map_lock); for (auto const& t : all_threads) { - if (pthread_equal (t.first, pthread_self ()) != 0) { + if (pthread_equal (t.first, pthread_self ())) { continue; } DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Cancel: '%1'\n", t.second)); @@ -292,7 +302,7 @@ pthread_cancel_one (pthread_t thread) { pthread_mutex_lock (&thread_map_lock); for (auto const& t : all_threads) { - if (pthread_equal (t.first, thread) != 0) { + if (pthread_equal (t.first, thread)) { all_threads.erase (t.first); break; } @@ -588,7 +598,7 @@ PBD::Thread::_run (void* arg) /* cleanup */ pthread_mutex_lock (&thread_map_lock); for (auto const& t : all_threads) { - if (pthread_equal (t.first, pthread_self ()) != 0) { + if (pthread_equal (t.first, pthread_self ())) { DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second)); all_threads.erase (t.first); break; @@ -611,5 +621,5 @@ PBD::Thread::join () bool PBD::Thread::caller_is_self () const { - return pthread_equal (_t, pthread_self ()) != 0; + return pthread_equal (_t, pthread_self ()); }