From 4998b114ea74241408ee32365b52ff0693d95b3a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 9 Nov 2025 20:14:32 +0100 Subject: [PATCH] First batch of change of waf/MSVC specific changes from EZ4Stephen --- libs/pbd/cartesian.cc | 3 +++ libs/pbd/crossthread.cc | 3 +++ libs/pbd/pbd/pthread_utils.h | 2 +- libs/pbd/pbd/scoped_file_descriptor.h | 2 ++ libs/pbd/pthread_utils.cc | 12 ++++++------ libs/pbd/system_exec.cc | 7 +++++-- libs/pbd/windows_special_dirs.cc | 4 ++++ 7 files changed, 24 insertions(+), 9 deletions(-) diff --git a/libs/pbd/cartesian.cc b/libs/pbd/cartesian.cc index 9f2a868309..69483e0c75 100644 --- a/libs/pbd/cartesian.cc +++ b/libs/pbd/cartesian.cc @@ -15,6 +15,9 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifdef COMPILER_MSVC +#define _USE_MATH_DEFINES +#endif #include diff --git a/libs/pbd/crossthread.cc b/libs/pbd/crossthread.cc index bf21d2befc..a6eeb612bd 100644 --- a/libs/pbd/crossthread.cc +++ b/libs/pbd/crossthread.cc @@ -21,7 +21,10 @@ #include #include #include + +#ifdef HAVE_UNISTD_H #include +#endif #ifdef PLATFORM_WINDOWS #include diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h index b864205791..4324cde9cc 100644 --- a/libs/pbd/pbd/pthread_utils.h +++ b/libs/pbd/pbd/pthread_utils.h @@ -29,7 +29,7 @@ #define PTHREAD_MACROS_DEFINED #ifdef PTW32_VERSION /* pthread_win32 */ #define mark_pthread_inactive(threadID) threadID.p=0 -#define is_pthread_active(threadID) threadID.p!=0 +#define is_pthread_active(threadID) (threadID.p!=0) #else /* normal pthread */ #define mark_pthread_inactive(threadID) threadID=0 #define is_pthread_active(threadID) threadID!=0 diff --git a/libs/pbd/pbd/scoped_file_descriptor.h b/libs/pbd/pbd/scoped_file_descriptor.h index 0d525275aa..a341992e96 100644 --- a/libs/pbd/pbd/scoped_file_descriptor.h +++ b/libs/pbd/pbd/scoped_file_descriptor.h @@ -18,7 +18,9 @@ #pragma once +#ifdef HAVE_UNISTD_H #include +#endif namespace PBD { diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc index c3d54afc80..67f8ac3589 100644 --- a/libs/pbd/pthread_utils.cc +++ b/libs/pbd/pthread_utils.cc @@ -194,7 +194,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 ())) { + if (pthread_equal (t.first, pthread_self ()) != 0) { DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second)); all_threads.erase (t.first); break; @@ -262,7 +262,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 ())) { + if (pthread_equal (t.first, pthread_self ()) != 0) { continue; } DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Kill: '%1'\n", t.second)); @@ -277,7 +277,7 @@ pthread_cancel_all () { pthread_mutex_lock (&thread_map_lock); for (auto const& t : all_threads) { - if (pthread_equal (t.first, pthread_self ())) { + if (pthread_equal (t.first, pthread_self ()) != 0) { continue; } DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Cancel: '%1'\n", t.second)); @@ -292,7 +292,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)) { + if (pthread_equal (t.first, thread) != 0) { all_threads.erase (t.first); break; } @@ -443,7 +443,7 @@ pbd_set_thread_priority (pthread_t thread, int policy, int priority) DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Change '%1' to policy = %2 priority = %3\n", pthread_name(), policy, param.sched_priority)); #ifdef PLATFORM_WINDOWS - if (is_pthread_active (thread) && param.sched_priority >= 12) { + if (thread.p != 0 && param.sched_priority >= 12) { if (set_win_set_realtime_policy (thread, param.sched_priority)) { return 0; } @@ -588,7 +588,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 ())) { + if (pthread_equal (t.first, pthread_self ()) != 0) { DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second)); all_threads.erase (t.first); break; diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc index 8570dfa598..cc514a01d2 100644 --- a/libs/pbd/system_exec.cc +++ b/libs/pbd/system_exec.cc @@ -18,14 +18,17 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + +#include #include #include #include #include -#include #include -#include +#ifdef HAVE_UNISTD_H +#include +#endif #ifndef COMPILER_MSVC #include diff --git a/libs/pbd/windows_special_dirs.cc b/libs/pbd/windows_special_dirs.cc index 713677675f..e19eb65c42 100644 --- a/libs/pbd/windows_special_dirs.cc +++ b/libs/pbd/windows_special_dirs.cc @@ -23,6 +23,10 @@ #include "pbd/windows_special_dirs.h" +#if defined (COMPILER_MSVC) && !defined (PATH_MAX) +#define PATH_MAX _MAX_PATH +#endif + std::string PBD::get_win_special_folder_path (int csidl) {