Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/libs/pbd/cpus.cc b/libs/pbd/cpus.cc
- index d43591ce30..bfa54b8a9d 100644
- --- a/libs/pbd/cpus.cc
- +++ b/libs/pbd/cpus.cc
- @@ -35,9 +35,6 @@
- #include "pbd/cpus.h"
- -#if defined(COMPILER_MSVC) && !defined(PTW32_VERSION)
- -#include <ardourext/pthread.h> // Gets us 'PTW32_VERSION'
- -#endif
- int32_t
- PBD::max_mmcss_threads_per_process ()
- @@ -69,7 +66,9 @@ PBD::hardware_concurrency()
- return c;
- }
- }
- -#if defined(PTW32_VERSION) || defined(__hpux)
- +#if defined(PLATFORM_WINDOWS)
- + return GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
- +#elif defined(PTW32_VERSION) || defined(__hpux)
- return pthread_num_processors_np();
- #elif defined(__APPLE__)
- int count;
- diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc
- index 232c29486f..6c52e83df0 100644
- --- a/libs/pbd/file_utils.cc
- +++ b/libs/pbd/file_utils.cc
- @@ -59,7 +59,6 @@
- /* close(), read(), write() */
- #ifdef COMPILER_MSVC
- #include <io.h> // Microsoft's nearest equivalent to <unistd.h>
- -#include <ardourext/misc.h>
- #else
- #endif
- diff --git a/libs/pbd/pbd/debug.h b/libs/pbd/pbd/debug.h
- index 7efea83d11..28270cf550 100644
- --- a/libs/pbd/pbd/debug.h
- +++ b/libs/pbd/pbd/debug.h
- @@ -31,7 +31,7 @@
- /* check for PTW32_VERSION */
- #ifdef COMPILER_MSVC
- -#include <ardourext/pthread.h>
- +#include <_ptw32.h>
- #else
- #include <pthread.h>
- #endif
- diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h
- index 4324cde9cc..28f2965eeb 100644
- --- a/libs/pbd/pbd/pthread_utils.h
- +++ b/libs/pbd/pbd/pthread_utils.h
- @@ -25,8 +25,6 @@
- * 'libpthread' and 'libpthread_win32' (whose implementations
- * of 'pthread_t' are subtlely different)
- */
- -#ifndef PTHREAD_MACROS_DEFINED
- -#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)
- @@ -34,10 +32,9 @@
- #define mark_pthread_inactive(threadID) threadID=0
- #define is_pthread_active(threadID) threadID!=0
- #endif /* PTW32_VERSION */
- -#endif /* PTHREAD_MACROS_DEFINED */
- #ifdef COMPILER_MSVC
- -#include <ardourext/pthread.h>
- +#include <_ptw32.h>
- #else
- #include <pthread.h>
- #endif
- diff --git a/libs/pbd/pbd/stack_allocator.h b/libs/pbd/pbd/stack_allocator.h
- index b5a907711b..859f244445 100644
- --- a/libs/pbd/pbd/stack_allocator.h
- +++ b/libs/pbd/pbd/stack_allocator.h
- @@ -31,6 +31,10 @@
- # define DEBUG_STACK_ALLOC(...)
- #endif
- +#ifdef COMPILER_MSVC
- +#undef max
- +#endif
- +
- namespace PBD {
- template <class T, std::size_t stack_capacity>
- diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h
- index 5d93d451ac..ef3ec04692 100644
- --- a/libs/pbd/pbd/undo.h
- +++ b/libs/pbd/pbd/undo.h
- @@ -31,8 +31,6 @@
- #ifndef COMPILER_MSVC
- #include <sys/time.h>
- -#else
- -#include <ardourext/misc.h>
- #endif
- #include "pbd/command.h"
- diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc
- index d2d24f38c4..5e97b0c573 100644
- --- a/libs/pbd/pthread_utils.cc
- +++ b/libs/pbd/pthread_utils.cc
- @@ -38,13 +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.
- -
- -#define pthread_gethandle pthread_getw32threadhandle_np
- +inline bool operator<(const pthread_t& lhs, const pthread_t& rhs) {
- + return lhs.p < rhs.p || (lhs.p == rhs.p && lhs.x < rhs.x);
- +}
- +inline bool operator==(const pthread_t& lhs, const pthread_t& rhs) {
- + return lhs.p == rhs.p && lhs.x == rhs.x;
- +}
- +inline bool operator!=(const pthread_t& lhs, const pthread_t& rhs) {
- + return !(lhs == rhs);
- +}
- +inline bool operator==(const pthread_t& lhs, int rhs) {
- + return rhs == 0 && lhs.p == nullptr;
- +}
- +inline bool operator!=(const pthread_t& lhs, int rhs) {
- + return rhs != 0 || lhs.p != nullptr;
- +}
- #endif
- #ifdef __APPLE__
- @@ -89,14 +97,14 @@ set_win_set_realtime_policy (pthread_t thread, int priority)
- if (SetPriorityClass (GetCurrentProcess (), 0x00000100 /* REALTIME_PRIORITY_CLASS */)) {
- /* see https://learn.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities */
- - ok = SetThreadPriority (pthread_gethandle (thread), priority);
- + ok = SetThreadPriority (pthread_getw32threadhandle_np (thread), priority);
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Using Windows RT thread class. set priority: %1\n", ok ? "OK" : GetLastErrorAsString ()));
- } else {
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Cannot use Windows RT thread class: %1\n", GetLastErrorAsString ()));
- ok = SetPriorityClass (GetCurrentProcess (), 0x00000080 /* HIGH_PRIORITY_CLASS */);
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Using Windows high priority thread class: %1\n", ok ? "OK" : GetLastErrorAsString ()));
- if (ok) {
- - ok = SetThreadPriority (pthread_gethandle (thread), priority);
- + ok = SetThreadPriority (pthread_getw32threadhandle_np (thread), priority);
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Set Windows high thread priority: %1\n", ok ? "OK" : GetLastErrorAsString ()));
- }
- }
- @@ -194,7 +202,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 (t.first == pthread_self ()) {
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second));
- all_threads.erase (t.first);
- break;
- @@ -262,7 +270,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 (t.first == pthread_self ()) {
- continue;
- }
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Kill: '%1'\n", t.second));
- @@ -277,7 +285,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 (t.first == pthread_self ()) {
- continue;
- }
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Cancel: '%1'\n", t.second));
- @@ -588,7 +596,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 (t.first == pthread_self ()) {
- DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second));
- all_threads.erase (t.first);
- break;
- @@ -611,5 +619,5 @@ PBD::Thread::join ()
- bool
- PBD::Thread::caller_is_self () const
- {
- - return pthread_equal (_t, pthread_self ()) != 0;
- + return _t == pthread_self ();
- }
- diff --git a/wscript b/wscript
- index 4b36f23048..4a6f496961 100644
- --- a/wscript
- +++ b/wscript
- @@ -1262,8 +1262,16 @@ int main () { return 0; }
- # see http://gareus.org/wiki/ardour_windows_gdk_and_cairo
- conf.env.append_value('CFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
- conf.env.append_value('CXXFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
- + conf.env.append_value('LIB', 'pthreadVC3')
- + conf.env.append_value('LIB', 'ws2_32')
- + conf.env.append_value('LIB', 'winmm')
- + conf.env.append_value('LIB', 'advapi32')
- + conf.env.append_value('LIB', 'shell32')
- + conf.env.append_value('LIB', 'user32')
- + conf.env.append_value('LIB', 'dbghelp')
- # MORE STUFF PROBABLY NEEDED HERE
- conf.define ('WINDOWS', 1)
Advertisement
Add Comment
Please, Sign In to add comment