Guest User

pbd and wscript diffs (for now)

a guest
Nov 12th, 2025
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.46 KB | None | 0 0
  1. diff --git a/libs/pbd/cpus.cc b/libs/pbd/cpus.cc
  2. index d43591ce30..bfa54b8a9d 100644
  3. --- a/libs/pbd/cpus.cc
  4. +++ b/libs/pbd/cpus.cc
  5. @@ -35,9 +35,6 @@
  6.  
  7. #include "pbd/cpus.h"
  8.  
  9. -#if defined(COMPILER_MSVC) && !defined(PTW32_VERSION)
  10. -#include <ardourext/pthread.h> // Gets us 'PTW32_VERSION'
  11. -#endif
  12.  
  13. int32_t
  14. PBD::max_mmcss_threads_per_process ()
  15. @@ -69,7 +66,9 @@ PBD::hardware_concurrency()
  16. return c;
  17. }
  18. }
  19. -#if defined(PTW32_VERSION) || defined(__hpux)
  20. +#if defined(PLATFORM_WINDOWS)
  21. + return GetActiveProcessorCount(ALL_PROCESSOR_GROUPS);
  22. +#elif defined(PTW32_VERSION) || defined(__hpux)
  23. return pthread_num_processors_np();
  24. #elif defined(__APPLE__)
  25. int count;
  26. diff --git a/libs/pbd/file_utils.cc b/libs/pbd/file_utils.cc
  27. index 232c29486f..6c52e83df0 100644
  28. --- a/libs/pbd/file_utils.cc
  29. +++ b/libs/pbd/file_utils.cc
  30. @@ -59,7 +59,6 @@
  31. /* close(), read(), write() */
  32. #ifdef COMPILER_MSVC
  33. #include <io.h> // Microsoft's nearest equivalent to <unistd.h>
  34. -#include <ardourext/misc.h>
  35. #else
  36. #endif
  37.  
  38. diff --git a/libs/pbd/pbd/debug.h b/libs/pbd/pbd/debug.h
  39. index 7efea83d11..28270cf550 100644
  40. --- a/libs/pbd/pbd/debug.h
  41. +++ b/libs/pbd/pbd/debug.h
  42. @@ -31,7 +31,7 @@
  43.  
  44. /* check for PTW32_VERSION */
  45. #ifdef COMPILER_MSVC
  46. -#include <ardourext/pthread.h>
  47. +#include <_ptw32.h>
  48. #else
  49. #include <pthread.h>
  50. #endif
  51. diff --git a/libs/pbd/pbd/pthread_utils.h b/libs/pbd/pbd/pthread_utils.h
  52. index 4324cde9cc..28f2965eeb 100644
  53. --- a/libs/pbd/pbd/pthread_utils.h
  54. +++ b/libs/pbd/pbd/pthread_utils.h
  55. @@ -25,8 +25,6 @@
  56. * 'libpthread' and 'libpthread_win32' (whose implementations
  57. * of 'pthread_t' are subtlely different)
  58. */
  59. -#ifndef PTHREAD_MACROS_DEFINED
  60. -#define PTHREAD_MACROS_DEFINED
  61. #ifdef PTW32_VERSION /* pthread_win32 */
  62. #define mark_pthread_inactive(threadID) threadID.p=0
  63. #define is_pthread_active(threadID) (threadID.p!=0)
  64. @@ -34,10 +32,9 @@
  65. #define mark_pthread_inactive(threadID) threadID=0
  66. #define is_pthread_active(threadID) threadID!=0
  67. #endif /* PTW32_VERSION */
  68. -#endif /* PTHREAD_MACROS_DEFINED */
  69.  
  70. #ifdef COMPILER_MSVC
  71. -#include <ardourext/pthread.h>
  72. +#include <_ptw32.h>
  73. #else
  74. #include <pthread.h>
  75. #endif
  76. diff --git a/libs/pbd/pbd/stack_allocator.h b/libs/pbd/pbd/stack_allocator.h
  77. index b5a907711b..859f244445 100644
  78. --- a/libs/pbd/pbd/stack_allocator.h
  79. +++ b/libs/pbd/pbd/stack_allocator.h
  80. @@ -31,6 +31,10 @@
  81. # define DEBUG_STACK_ALLOC(...)
  82. #endif
  83.  
  84. +#ifdef COMPILER_MSVC
  85. +#undef max
  86. +#endif
  87. +
  88. namespace PBD {
  89.  
  90. template <class T, std::size_t stack_capacity>
  91. diff --git a/libs/pbd/pbd/undo.h b/libs/pbd/pbd/undo.h
  92. index 5d93d451ac..ef3ec04692 100644
  93. --- a/libs/pbd/pbd/undo.h
  94. +++ b/libs/pbd/pbd/undo.h
  95. @@ -31,8 +31,6 @@
  96.  
  97. #ifndef COMPILER_MSVC
  98. #include <sys/time.h>
  99. -#else
  100. -#include <ardourext/misc.h>
  101. #endif
  102.  
  103. #include "pbd/command.h"
  104. diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc
  105. index d2d24f38c4..5e97b0c573 100644
  106. --- a/libs/pbd/pthread_utils.cc
  107. +++ b/libs/pbd/pthread_utils.cc
  108. @@ -38,13 +38,21 @@
  109. #include "pbd/pthread_utils.h"
  110.  
  111. #ifdef COMPILER_MSVC
  112. -DECLARE_DEFAULT_COMPARISONS (pthread_t) // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
  113. - // searched and sorted. Thus, when instantiating the container, MSVC complains
  114. - // if the type of object being contained has no appropriate comparison operators
  115. - // defined (specifically, if operators '<' and '==' are undefined). This seems
  116. - // to be the case with ptw32 'pthread_t' which is a simple struct.
  117. -
  118. -#define pthread_gethandle pthread_getw32threadhandle_np
  119. +inline bool operator<(const pthread_t& lhs, const pthread_t& rhs) {
  120. + return lhs.p < rhs.p || (lhs.p == rhs.p && lhs.x < rhs.x);
  121. +}
  122. +inline bool operator==(const pthread_t& lhs, const pthread_t& rhs) {
  123. + return lhs.p == rhs.p && lhs.x == rhs.x;
  124. +}
  125. +inline bool operator!=(const pthread_t& lhs, const pthread_t& rhs) {
  126. + return !(lhs == rhs);
  127. +}
  128. +inline bool operator==(const pthread_t& lhs, int rhs) {
  129. + return rhs == 0 && lhs.p == nullptr;
  130. +}
  131. +inline bool operator!=(const pthread_t& lhs, int rhs) {
  132. + return rhs != 0 || lhs.p != nullptr;
  133. +}
  134. #endif
  135.  
  136. #ifdef __APPLE__
  137. @@ -89,14 +97,14 @@ set_win_set_realtime_policy (pthread_t thread, int priority)
  138.  
  139. if (SetPriorityClass (GetCurrentProcess (), 0x00000100 /* REALTIME_PRIORITY_CLASS */)) {
  140. /* see https://learn.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities */
  141. - ok = SetThreadPriority (pthread_gethandle (thread), priority);
  142. + ok = SetThreadPriority (pthread_getw32threadhandle_np (thread), priority);
  143. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Using Windows RT thread class. set priority: %1\n", ok ? "OK" : GetLastErrorAsString ()));
  144. } else {
  145. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Cannot use Windows RT thread class: %1\n", GetLastErrorAsString ()));
  146. ok = SetPriorityClass (GetCurrentProcess (), 0x00000080 /* HIGH_PRIORITY_CLASS */);
  147. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Using Windows high priority thread class: %1\n", ok ? "OK" : GetLastErrorAsString ()));
  148. if (ok) {
  149. - ok = SetThreadPriority (pthread_gethandle (thread), priority);
  150. + ok = SetThreadPriority (pthread_getw32threadhandle_np (thread), priority);
  151. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Set Windows high thread priority: %1\n", ok ? "OK" : GetLastErrorAsString ()));
  152. }
  153. }
  154. @@ -194,7 +202,7 @@ fake_thread_start (void* arg)
  155. pthread_mutex_lock (&thread_map_lock);
  156.  
  157. for (auto const& t : all_threads) {
  158. - if (pthread_equal (t.first, pthread_self ()) != 0) {
  159. + if (t.first == pthread_self ()) {
  160. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second));
  161. all_threads.erase (t.first);
  162. break;
  163. @@ -262,7 +270,7 @@ pthread_kill_all (int signum)
  164. {
  165. pthread_mutex_lock (&thread_map_lock);
  166. for (auto const& t : all_threads) {
  167. - if (pthread_equal (t.first, pthread_self ()) != 0) {
  168. + if (t.first == pthread_self ()) {
  169. continue;
  170. }
  171. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Kill: '%1'\n", t.second));
  172. @@ -277,7 +285,7 @@ pthread_cancel_all ()
  173. {
  174. pthread_mutex_lock (&thread_map_lock);
  175. for (auto const& t : all_threads) {
  176. - if (pthread_equal (t.first, pthread_self ()) != 0) {
  177. + if (t.first == pthread_self ()) {
  178. continue;
  179. }
  180. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Cancel: '%1'\n", t.second));
  181. @@ -588,7 +596,7 @@ PBD::Thread::_run (void* arg)
  182. /* cleanup */
  183. pthread_mutex_lock (&thread_map_lock);
  184. for (auto const& t : all_threads) {
  185. - if (pthread_equal (t.first, pthread_self ()) != 0) {
  186. + if (t.first == pthread_self ()) {
  187. DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second));
  188. all_threads.erase (t.first);
  189. break;
  190. @@ -611,5 +619,5 @@ PBD::Thread::join ()
  191. bool
  192. PBD::Thread::caller_is_self () const
  193. {
  194. - return pthread_equal (_t, pthread_self ()) != 0;
  195. + return _t == pthread_self ();
  196. }
  197. diff --git a/wscript b/wscript
  198. index 4b36f23048..4a6f496961 100644
  199. --- a/wscript
  200. +++ b/wscript
  201. @@ -1262,8 +1262,16 @@ int main () { return 0; }
  202. # see http://gareus.org/wiki/ardour_windows_gdk_and_cairo
  203. conf.env.append_value('CFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
  204. conf.env.append_value('CXXFLAGS', '-DUSE_CAIRO_IMAGE_SURFACE')
  205. + conf.env.append_value('LIB', 'pthreadVC3')
  206. + conf.env.append_value('LIB', 'ws2_32')
  207. + conf.env.append_value('LIB', 'winmm')
  208. + conf.env.append_value('LIB', 'advapi32')
  209. + conf.env.append_value('LIB', 'shell32')
  210. + conf.env.append_value('LIB', 'user32')
  211. + conf.env.append_value('LIB', 'dbghelp')
  212. # MORE STUFF PROBABLY NEEDED HERE
  213. conf.define ('WINDOWS', 1)
Advertisement
Add Comment
Please, Sign In to add comment