emzeat / xdispatch2

Grand Central Dispatch like C++ threading library built around queues, thread pools and flexible backends
https://emzeat.de/xdispatch2
Apache License 2.0
12 stars 2 forks source link

Some errors in `libdispatch` backend when building on 10.6 #2

Closed barracuda156 closed 6 months ago

barracuda156 commented 7 months ago

@emzeat I tried to build this against libdispatch-legacy port, which in fact is just Apple-released libdispatch for 10.6.8 (it is built as a separate static library, not a part of libSystem, but headers are identical and presumably symbol are).

It does not [yet] work:

[ 64%] Building CXX object CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o
/opt/local/bin/g++-mp-13 -Dxdispatch_EXPORTS -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/build/include -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/include -pipe -Os -DNDEBUG -I/opt/local/include -I/opt/local/libexec/dispatch/usr/include -D_GLIBCXX_USE_CXX11_ABI=0 -DDEBUG=1 -Wall -Werror -Wno-unused-function -DMZ_MACOS=1 -fno-stack-check -DMZ_HAS_CXX11=1 -DMZ_HAS_CXX0X=1 -fvisibility=hidden -Wno-unused-but-set-variable -Wno-deprecated-declarations -DXDISPATCH_MAKEDLL -std=gnu++14 -arch ppc -mmacosx-version-min=10.6 -fPIC -MD -MT CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o -MF CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o.d -o CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_timer.cpp
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_execution.cpp: In function 'void xdispatch::libdispatch::set_debugger_threadname_from_queue()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_execution.cpp:37:36: error: 'DISPATCH_CURRENT_QUEUE_LABEL' was not declared in this scope
   37 |           dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL));
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_execution.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_group.cpp: In member function 'virtual bool xdispatch::libdispatch::group_impl::wait(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_group.cpp:66:61: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   66 |           DISPATCH_TIME_NOW, std::int64_t(timeout.count() * NSEC_PER_MSEC));
      |                                                             ^~~~~~~~~~~~~
      |                                                             NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_queue.cpp: In member function 'virtual void xdispatch::libdispatch::queue_impl::after(std::chrono::milliseconds, const xdispatch::operation_ptr&)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_queue.cpp:65:59: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   65 |           DISPATCH_TIME_NOW, std::int64_t(delay.count() * NSEC_PER_MSEC));
      |                                                           ^~~~~~~~~~~~~
      |                                                           NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_queue.cpp: In member function 'virtual xdispatch::iqueue_impl_ptr xdispatch::libdispatch::backend::create_serial_queue(const std::string&, xdispatch::queue_priority)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_queue.cpp:105:7: error: 'DISPATCH_QUEUE_SERIAL' was not declared in this scope; did you mean 'XDISPATCH_QUEUE_H_'?
  105 |       DISPATCH_QUEUE_SERIAL, thread_utils::map_priority_to_qos(priority), 0);
      |       ^~~~~~~~~~~~~~~~~~~~~
      |       XDISPATCH_QUEUE_H_
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_queue.cpp:105:44: error: 'map_priority_to_qos' is not a member of 'xdispatch::thread_utils'
  105 |       DISPATCH_QUEUE_SERIAL, thread_utils::map_priority_to_qos(priority), 0);
      |                                            ^~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_queue.cpp:104:38: error: 'dispatch_queue_attr_make_with_qos_class' was not declared in this scope
  104 |     dispatch_queue_attr_t qos_attr = dispatch_queue_attr_make_with_qos_class(
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_queue.cpp: In member function 'virtual xdispatch::iqueue_impl_ptr xdispatch::libdispatch::backend::create_parallel_queue(const std::string&, xdispatch::queue_priority)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_queue.cpp:115:36: error: 'map_priority_to_qos' is not a member of 'xdispatch::thread_utils'
  115 |     const auto qos = thread_utils::map_priority_to_qos(priority);
      |                                    ^~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_group.cpp.o] Error 1
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_queue.cpp.o] Error 1
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_socket_notifier.cpp: In member function 'virtual void xdispatch::libdispatch::socket_notifier_impl::handler(const xdispatch::socket_notifier_operation_ptr&)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_socket_notifier.cpp:70:53: error: expected primary-expression before '^' token
   70 |         dispatch_source_set_event_handler(m_native, ^{
      |                                                     ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_socket_notifier.cpp:70:54: error: expected primary-expression before '{' token
   70 |         dispatch_source_set_event_handler(m_native, ^{
      |                                                      ^
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_socket_notifier.cpp:70:9: error: 'dispatch_source_set_event_handler' was not declared in this scope; did you mean 'dispatch_source_set_event_handler_f'?
   70 |         dispatch_source_set_event_handler(m_native, ^{
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         dispatch_source_set_event_handler_f
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_socket_notifier.cpp:66:20: error: unused variable 'socket' [-Werror=unused-variable]
   66 |         const auto socket = m_socket;
      |                    ^~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_socket_notifier.cpp:67:20: error: unused variable 'type' [-Werror=unused-variable]
   67 |         const auto type = m_type;
      |                    ^~~~
cc1plus: all warnings being treated as errors
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::interval(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_timer.cpp:56:41: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   56 |         m_interval = interval.count() * NSEC_PER_MSEC;
      |                                         ^~~~~~~~~~~~~
      |                                         NSEC_PER_USEC
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_socket_notifier.cpp.o] Error 1
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::latency(xdispatch::timer_precision)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_timer.cpp:69:23: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   69 |                   5 * NSEC_PER_MSEC; // NOLINT(readability-magic-numbers)
      |                       ^~~~~~~~~~~~~
      |                       NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::resume(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/v2.1.3/src/libdispatch/libdispatch_timer.cpp:97:63: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   97 |               DISPATCH_TIME_NOW, std::int64_t(delay.count() * NSEC_PER_MSEC));
      |                                                               ^~~~~~~~~~~~~
      |                                                               NSEC_PER_USEC
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/build'
make[1]: *** [CMakeFiles/xdispatch.dir/all] Error 2

Does it look fixable?

Apple source is here: https://github.com/apple-oss-distributions/libdispatch/tree/libdispatch-84.5.5

barracuda156 commented 7 months ago

Naive backend builds fine on 10.6 ppc, and reports tests as passing, though there are multiple Failed to set priority 2 for thread: Unknown error: -1 warnings. Not sure how concerning are those.

--->  Testing xdispatch2
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/build" && /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/build/bin/xdispatch2_tests 

   MUnit Test Framework with independent processes
   (c) 2011 MLBA

Running all Tests
==================================
(1) Running test 'naive__cxx_dispatch_group'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1

    -> sleeping...
    -> sleeping...
    -> sleeping...
    -> done.
    -> done.
    -> done.
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(2) Running test 'naive__cxx_dispatch_mainqueue'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(3) Running test 'naive__cxx_dispatch_timer_main'...
[xdispatch2]    -> Testing periodic timer
Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    ->  0
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(4) Running test 'naive__cxx_dispatch_timer_global'...
    -> Testing periodic timer
[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority     ->  0
0 for thread: Unknown error: -1
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(5) Running test 'naive__cxx_dispatch_timer_serial'...
    -> Testing periodic timer
[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    ->  0
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(6) Running test 'naive__cxx_dispatch_timer_suspend'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(7) Running test 'naive__cxx_dispatch_timer_cancel'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(8) Running test 'naive__cxx_dispatch_after_main'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(9) Running test 'naive__cxx_dispatch_after_global'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(10) Running test 'naive__cxx_dispatch_after_serial'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(11) Running test 'naive__cxx_dispatch_notifier_read'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1

    -> READ handler call
    PASS
(12) Running test 'naive__cxx_dispatch_notifier_write'...
    -> 8192 bytes until saturated
[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    -> WRITE handler call
    PASS
(13) Running test 'naive__cxx_dispatch_notifier_suspend'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1

    -> Initial handler call, suspending
    PASS
(14) Running test 'naive__cxx_dispatch_notifier_cancel'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1

[xdispatch2] Failed to set priority 0 for thread:   -> Initial handler call, canceling
Unknown error: -1
    PASS
(15) Running test 'naive__cxx_dispatch_cascade_lambda'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(16) Running test 'naive__cxx_dispatch_group_lambda'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1

    -> sleeping...
    -> sleeping...
    -> sleeping...
    -> done.
    -> done.
    -> done.
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(17) Running test 'naive__cxx_dispatch_queue_lambda'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(18) Running test 'naive__cxx_dispatch_serialqueue_lambda'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(19) Running test 'naive__cxx_free_lambda'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(20) Running test 'naive__cxx_dispatch_priority_custom'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1

    -> cxx_dispatch_priority_custom_BACKGROUND: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_UTILITY: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_USER_INITIATED: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_USER_INTERACTIVE: 64
****************************************                                        
    PASS
(21) Running test 'naive__cxx_dispatch_priority_global'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1

    -> cxx_dispatch_priority_custom_BACKGROUND: 5
***                                                                             
    -> cxx_dispatch_priority_custom_UTILITY: 0

    -> cxx_dispatch_priority_custom_USER_INITIATED: 123
****************************************************************************    
    -> cxx_dispatch_priority_custom_USER_INTERACTIVE: 128
********************************************************************************
    PASS
(22) Running test 'naive__cxx_benchmark_serial_queue'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1

    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS
(23) Running test 'naive__cxx_benchmark_global_queue'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1

    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS
(24) Running test 'naive__cxx_benchmark_group'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1

    -> Dispatched 100000 operations, 0 nsec per operation
[xdispatch2] Failed to set priority     -> Executed 100000 operations, 0 nsec per operation
0    PASS
 for thread: Unknown error: -1
(25) Running test 'naive__cxx_waitable_queue'...    PASS
(26) Running test 'platform_test_main_queue'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
    PASS
(27) Running test 'platform_test_global_queue<xdispatch::queue_priority::USER_INTERACTIVE>'...    PASS
[xdispatch2] Failed to set priority (28) Running test 'platform_test_global_queue<xdispatch::queue_priority::USER_INITIATED>'...[xdispatch2] Failed to set priority 2 for thread:     PASS
Unknown error: -1
(29) Running test 'platform_test_global_queue<xdispatch::queue_priority::UTILITY>'...[xdispatch2] Failed to set priority 2    PASS
 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 0(30) Running test 'platform_test_global_queue<xdispatch::queue_priority::DEFAULT>'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(31) Running test 'platform_test_global_queue<xdispatch::queue_priority::BACKGROUND>'...[xdispatch2] Failed to set priority 2    PASS
 for thread: Unknown error: -1
[xdispatch2] Failed to set priority (32) Running test 'platform_test_custom_queue'...[xdispatch2] Failed to set priority 2    PASS
 for thread: Unknown error: -1
(33) Running test 'platform_test_timer'...[xdispatch2] Failed to set priority 2 for thread:     PASS
(34) Running test 'platform_test_group'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(35) Running test 'signal_test_void_connection'...[xdispatch2] Failed to set priority 2    PASS
 for thread: Unknown error: -1
(36) Running test 'signal_test_int_connection'...[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(37) Running test 'signal_test_disconnect'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(38) Running test 'signal_test_disconnect_dangling'...[xdispatch2]     PASS
Failed to set priority 2 for thread: (39) Running test 'signal_test_recursive_disconnect'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
[xdispatch2] Failed to set priority 0 for thread: Unknown error: -1
(40) Running test 'signal_test_barrier'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(41) Running test 'signal_test_barrier_pod_value'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(42) Running test 'signal_test_barrier_complex_value'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(43) Running test 'signal_test_scoped_connection'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(44) Running test 'signal_test_connection_manager'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(45) Running test 'signal_test_batch_updates'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(46) Running test 'signal_test_single_updates'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
(47) Running test 'signal_test_chaining'...[xdispatch2] Failed to set priority 2 for thread: Unknown error: -1
    PASS
==================================
ALL PASSED.
----------------------------------
Passed: 47  Failed: 0
emzeat commented 7 months ago

That's interesting, I had created 55f83528d277b1afec05f3279fba528234c844ee while testing compatibility with the current ports of libdispatch on Linux made to support Swift. I presume there is more feature tests required.

Are you on latest dev for sure?

barracuda156 commented 7 months ago

That's interesting, I had created 55f8352 while testing compatibility with the current ports of libdispatch on Linux made to support Swift. I presume there is more feature tests required.

Are you on latest dev for sure?

Ah, no, I built from released one, at least on 10.6. I will try dev branch, thank you.

barracuda156 commented 7 months ago

Still fails from 7e935017bcf1798204c50c459115b4ed8f52d268 commit (if libdispatch backend enabled):

[ 64%] Building CXX object CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o
/opt/local/bin/g++-mp-13 -Dxdispatch_EXPORTS -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/build/include -I/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/include -pipe -Os -DNDEBUG -I/opt/local/include -I/opt/local/libexec/dispatch/usr/include -D_GLIBCXX_USE_CXX11_ABI=0 -DDEBUG=1 -Wall -Werror -Wno-unused-function -DMZ_MACOS=1 -fno-stack-check -DMZ_HAS_CXX11=1 -DMZ_HAS_CXX0X=1 -fvisibility=hidden -Wno-unused-but-set-variable -Wno-deprecated-declarations -DXDISPATCH_MAKEDLL -std=gnu++14 -arch ppc -mmacosx-version-min=10.6 -fPIC -MD -MT CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o -MF CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o.d -o CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o -c /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_timer.cpp
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_group.cpp: In member function 'virtual bool xdispatch::libdispatch::group_impl::wait(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_group.cpp:66:61: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   66 |           DISPATCH_TIME_NOW, std::int64_t(timeout.count() * NSEC_PER_MSEC));
      |                                                             ^~~~~~~~~~~~~
      |                                                             NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_execution.cpp: In function 'void xdispatch::libdispatch::set_debugger_threadname_from_queue()':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_execution.cpp:37:36: error: 'DISPATCH_CURRENT_QUEUE_LABEL' was not declared in this scope
   37 |           dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL));
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_group.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_execution.cpp.o] Error 1
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp: In member function 'virtual void xdispatch::libdispatch::queue_impl::after(std::chrono::milliseconds, const xdispatch::operation_ptr&)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp:65:59: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   65 |           DISPATCH_TIME_NOW, std::int64_t(delay.count() * NSEC_PER_MSEC));
      |                                                           ^~~~~~~~~~~~~
      |                                                           NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp: At global scope:
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp:87:8: error: 'dispatch_qos_class_t' does not name a type; did you mean 'dispatch_source_t'?
   87 | static dispatch_qos_class_t
      |        ^~~~~~~~~~~~~~~~~~~~
      |        dispatch_source_t
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp: In member function 'virtual xdispatch::iqueue_impl_ptr xdispatch::libdispatch::backend::create_serial_queue(const std::string&, xdispatch::queue_priority)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp:133:7: error: 'DISPATCH_QUEUE_SERIAL' was not declared in this scope; did you mean 'XDISPATCH_QUEUE_H_'?
  133 |       DISPATCH_QUEUE_SERIAL, priority_2_native(priority), 0);
      |       ^~~~~~~~~~~~~~~~~~~~~
      |       XDISPATCH_QUEUE_H_
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp:133:30: error: 'priority_2_native' was not declared in this scope
  133 |       DISPATCH_QUEUE_SERIAL, priority_2_native(priority), 0);
      |                              ^~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp:132:38: error: 'dispatch_queue_attr_make_with_qos_class' was not declared in this scope
  132 |     dispatch_queue_attr_t qos_attr = dispatch_queue_attr_make_with_qos_class(
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp: In member function 'virtual xdispatch::iqueue_impl_ptr xdispatch::libdispatch::backend::create_parallel_queue(const std::string&, xdispatch::queue_priority)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_queue.cpp:143:22: error: 'priority_2_native' was not declared in this scope
  143 |     const auto qos = priority_2_native(priority);
      |                      ^~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_queue.cpp.o] Error 1
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::interval(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_timer.cpp:56:41: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   56 |         m_interval = interval.count() * NSEC_PER_MSEC;
      |                                         ^~~~~~~~~~~~~
      |                                         NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::latency(xdispatch::timer_precision)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_timer.cpp:69:23: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   69 |                   5 * NSEC_PER_MSEC; // NOLINT(readability-magic-numbers)
      |                       ^~~~~~~~~~~~~
      |                       NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::resume(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/7e935017bcf1798204c50c459115b4ed8f52d268/src/libdispatch/libdispatch_timer.cpp:97:63: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   97 |               DISPATCH_TIME_NOW, std::int64_t(delay.count() * NSEC_PER_MSEC));
      |                                                               ^~~~~~~~~~~~~
      |                                                               NSEC_PER_USEC
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2/xdispatch2/work/build'
make[1]: *** [CMakeFiles/xdispatch.dir/all] Error 2
emzeat commented 7 months ago

Naive backend builds fine on 10.6 ppc, and reports tests as passing, though there are multiple Failed to set priority 2 for thread: Unknown error: -1 warnings. Not sure how concerning are those.

Glad to hear that. The reporting error means the threads are not running with the expected priority which might impact balancing between the queues but is far from being fatal.

Fixing the missing NSEC_PER_MSEC is probably going to be easy by doing something along the lines of

#ifndef NSEC_PER_MSEC
#define NSEC_PER_MSEC ((1000 * NSEC_PER_USEC))
#endif

For the missing dispatch_queue_attr_make_with_qos_class function there will be a feature test required in CMakeLists.txt:40. Same for dispatch_queue_get_label, if I remember correctly this had to be mapped to dispatch_queue_get_label( dispatch_get_current_queue() ) before.

Unfortunately I won't have the capacity to help you on this anytime this week so you will need to try yourself.

emzeat commented 7 months ago

Please try #4 to resolve the error about setting priority.

barracuda156 commented 7 months ago

@emzeat Sorry for a delay, will do today.

barracuda156 commented 7 months ago

I think it does not yet work:

--->  Testing xdispatch2-devel
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/build" && /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/build/bin/xdispatch2_tests 

   MUnit Test Framework with independent processes
   (c) 2011 MLBA

Running all Tests
==================================
(1) Running test 'naive__cxx_dispatch_group'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument

    -> sleeping...
    -> sleeping...
    -> sleeping...
    -> done.
    -> done.
    -> done.
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(2) Running test 'naive__cxx_dispatch_mainqueue'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(3) Running test 'naive__cxx_dispatch_timer_main'...[xdispatch2] 
Failed to set priority  -> Testing periodic timer
2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    ->  0
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(4) Running test 'naive__cxx_dispatch_timer_global'...
    -> Testing periodic timer
[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    ->  0
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(5) Running test 'naive__cxx_dispatch_timer_serial'...
    -> Testing periodic timer
[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    ->  0
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(6) Running test 'naive__cxx_dispatch_timer_suspend'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(7) Running test 'naive__cxx_dispatch_timer_cancel'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(8) Running test 'naive__cxx_dispatch_after_main'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(9) Running test 'naive__cxx_dispatch_after_global'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(10) Running test 'naive__cxx_dispatch_after_serial'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(11) Running test 'naive__cxx_dispatch_notifier_read'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument

    -> READ handler call
    PASS
(12) Running test 'naive__cxx_dispatch_notifier_write'...
    -> 8192 bytes until saturated
[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    -> WRITE handler call
    PASS
(13) Running test 'naive__cxx_dispatch_notifier_suspend'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument

    -> Initial handler call, suspending
    PASS
(14) Running test 'naive__cxx_dispatch_notifier_cancel'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument

    -> Initial handler call, canceling
    PASS
(15) Running test 'naive__cxx_dispatch_cascade_lambda'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(16) Running test 'naive__cxx_dispatch_group_lambda'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument

    -> sleeping...
    -> sleeping...
    -> sleeping...
    -> done.
    -> done.
    -> done.
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(17) Running test 'naive__cxx_dispatch_queue_lambda'...[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(18) Running test 'naive__cxx_dispatch_serialqueue_lambda'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(19) Running test 'naive__cxx_free_lambda'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(20) Running test 'naive__cxx_dispatch_priority_custom'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument

    -> cxx_dispatch_priority_custom_BACKGROUND: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_UTILITY: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_USER_INITIATED: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_USER_INTERACTIVE: 64
****************************************                                        
    PASS
(21) Running test 'naive__cxx_dispatch_priority_global'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument

    -> cxx_dispatch_priority_custom_BACKGROUND: 8
*****                                                                           
    -> cxx_dispatch_priority_custom_UTILITY: 0

    -> cxx_dispatch_priority_custom_USER_INITIATED: 120
***************************************************************************     
    -> cxx_dispatch_priority_custom_USER_INTERACTIVE: 128
********************************************************************************
    PASS
(22) Running test 'naive__cxx_benchmark_serial_queue'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument

    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS
(23) Running test 'naive__cxx_benchmark_global_queue'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument

    -> Dispatched 99999 operations, 0 nsec per operation
    -> Executed 99999 operations, 0 nsec per operation
    PASS
(24) Running test 'naive__cxx_benchmark_group'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument

    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 99996 operations, 0 nsec per operation
    PASS
(25) Running test 'naive__cxx_waitable_queue'...    PASS
(26) Running test 'platform_test_main_queue'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(27) Running test 'platform_test_global_queue<xdispatch::queue_priority::USER_INTERACTIVE>'...[xdispatch2] Failed to set priority 0 for thread: Invalid argument
[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(28) Running test 'platform_test_global_queue<xdispatch::queue_priority::USER_INITIATED>'...[xdispatch2]     PASS
Failed to set priority 2 for thread: (29) Running test 'platform_test_global_queue<xdispatch::queue_priority::UTILITY>'...[xdispatch2] Failed to set priority 2    PASS
 for thread: Invalid argument
(30) Running test 'platform_test_global_queue<xdispatch::queue_priority::DEFAULT>'...[xdispatch2] Failed to set priority 0 for thread: Invalid argument    PASS

(31) Running test 'platform_test_global_queue<xdispatch::queue_priority::BACKGROUND>'...[xdispatch2] Failed to set priority 2 for thread:     PASS
Invalid argument
(32) Running test 'platform_test_custom_queue'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(33) Running test 'platform_test_timer'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
[xdispatch2] Failed to set priority 0 for thread: Invalid argument
    PASS
(34) Running test 'platform_test_group'...[xdispatch2] Failed to set priority 2 for thread:     PASS
Invalid argument
(35) Running test 'signal_test_void_connection'...[xdispatch2] Failed to set priority 2 for thread:     PASS
(36) Running test 'signal_test_int_connection'...[xdispatch2]     PASS
Failed to set priority 2 for thread: (37) Running test 'signal_test_disconnect'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(38) Running test 'signal_test_disconnect_dangling'...[xdispatch2] Failed to set priority     PASS
2 for thread: Invalid argument(39) Running test 'signal_test_recursive_disconnect'...[xdispatch2] Failed to set priority 2 for thread:     PASS
Invalid argument
(40) Running test 'signal_test_barrier'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(41) Running test 'signal_test_barrier_pod_value'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(42) Running test 'signal_test_barrier_complex_value'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(43) Running test 'signal_test_scoped_connection'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(44) Running test 'signal_test_connection_manager'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(45) Running test 'signal_test_batch_updates'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(46) Running test 'signal_test_single_updates'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
(47) Running test 'signal_test_chaining'...[xdispatch2] Failed to set priority 2 for thread: Invalid argument
    PASS
==================================
ALL PASSED.
----------------------------------
Passed: 47  Failed: 0

Used 58874f5a2ddc3beece8776e1b6c270fba51799c9 commit.

emzeat commented 7 months ago

At least the error message is meaningful now so that's some progress :)

emzeat commented 7 months ago

Using this I was now able to understand and replicate what's going wrong there. Please test on your system with latest dev again.

barracuda156 commented 7 months ago

@emzeat Great, so naive backend tests now pass, building from 6555aa253a6446dc5ee9f8e2516b89291a75d56d commit:

--->  Testing xdispatch2-devel
Executing:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/build" && /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/build/bin/xdispatch2_tests 

   MUnit Test Framework with independent processes
   (c) 2011 MLBA

Running all Tests
==================================
(1) Running test 'naive__cxx_dispatch_group'...
    -> sleeping...
    -> sleeping...
    -> sleeping...
    -> done.
    -> done.
    -> done.
    PASS
(2) Running test 'naive__cxx_dispatch_mainqueue'...    PASS
(3) Running test 'naive__cxx_dispatch_timer_main'...
    -> Testing periodic timer
    ->  0
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(4) Running test 'naive__cxx_dispatch_timer_global'...
    -> Testing periodic timer
    ->  0
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(5) Running test 'naive__cxx_dispatch_timer_serial'...
    -> Testing periodic timer
    ->  0
    ->  1
    ->  2
    ->  3
    ->  4
    ->  5
    PASS
(6) Running test 'naive__cxx_dispatch_timer_suspend'...    PASS
(7) Running test 'naive__cxx_dispatch_timer_cancel'...    PASS
(8) Running test 'naive__cxx_dispatch_after_main'...    PASS
(9) Running test 'naive__cxx_dispatch_after_global'...    PASS
(10) Running test 'naive__cxx_dispatch_after_serial'...    PASS
(11) Running test 'naive__cxx_dispatch_notifier_read'...
    -> READ handler call
    PASS
(12) Running test 'naive__cxx_dispatch_notifier_write'...
    -> 8192 bytes until saturated
    -> WRITE handler call
    PASS
(13) Running test 'naive__cxx_dispatch_notifier_suspend'...
    -> Initial handler call, suspending
    PASS
(14) Running test 'naive__cxx_dispatch_notifier_cancel'...
    -> Initial handler call, canceling
    PASS
(15) Running test 'naive__cxx_dispatch_cascade_lambda'...    PASS
(16) Running test 'naive__cxx_dispatch_group_lambda'...
    -> sleeping...
    -> sleeping...
    -> sleeping...
    -> done.
    -> done.
    -> done.
    PASS
(17) Running test 'naive__cxx_dispatch_queue_lambda'...    PASS
(18) Running test 'naive__cxx_dispatch_serialqueue_lambda'...    PASS
(19) Running test 'naive__cxx_free_lambda'...    PASS
(20) Running test 'naive__cxx_dispatch_priority_custom'...
    -> cxx_dispatch_priority_custom_BACKGROUND: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_UTILITY: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_USER_INITIATED: 64
****************************************                                        
    -> cxx_dispatch_priority_custom_USER_INTERACTIVE: 64
****************************************                                        
    PASS
(21) Running test 'naive__cxx_dispatch_priority_global'...
    -> cxx_dispatch_priority_custom_BACKGROUND: 1

    -> cxx_dispatch_priority_custom_UTILITY: 0

    -> cxx_dispatch_priority_custom_USER_INITIATED: 127
******************************************************************************* 
    -> cxx_dispatch_priority_custom_USER_INTERACTIVE: 128
********************************************************************************
    PASS
(22) Running test 'naive__cxx_benchmark_serial_queue'...
    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS
(23) Running test 'naive__cxx_benchmark_global_queue'...
    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS
(24) Running test 'naive__cxx_benchmark_group'...
    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 99999 operations, 0 nsec per operation
    PASS
(25) Running test 'naive__cxx_waitable_queue'...    PASS
(26) Running test 'platform_test_main_queue'...    PASS
(27) Running test 'platform_test_global_queue<xdispatch::queue_priority::USER_INTERACTIVE>'...    PASS
(28) Running test 'platform_test_global_queue<xdispatch::queue_priority::USER_INITIATED>'...    PASS
(29) Running test 'platform_test_global_queue<xdispatch::queue_priority::UTILITY>'...    PASS
(30) Running test 'platform_test_global_queue<xdispatch::queue_priority::DEFAULT>'...    PASS
(31) Running test 'platform_test_global_queue<xdispatch::queue_priority::BACKGROUND>'...    PASS
(32) Running test 'platform_test_custom_queue'...    PASS
(33) Running test 'platform_test_timer'...    PASS
(34) Running test 'platform_test_group'...    PASS
(35) Running test 'signal_test_void_connection'...    PASS
(36) Running test 'signal_test_int_connection'...    PASS
(37) Running test 'signal_test_disconnect'...    PASS
(38) Running test 'signal_test_disconnect_dangling'...    PASS
(39) Running test 'signal_test_recursive_disconnect'...    PASS
(40) Running test 'signal_test_barrier'...    PASS
(41) Running test 'signal_test_barrier_pod_value'...    PASS
(42) Running test 'signal_test_barrier_complex_value'...    PASS
(43) Running test 'signal_test_scoped_connection'...    PASS
(44) Running test 'signal_test_connection_manager'...    PASS
(45) Running test 'signal_test_batch_updates'...    PASS
(46) Running test 'signal_test_single_updates'...    PASS
(47) Running test 'signal_test_chaining'...    PASS
==================================
ALL PASSED.
----------------------------------
Passed: 47  Failed: 0

Thank you!

Could we do something about libdispatch errors too?

emzeat commented 6 months ago

I will try to look at this this week

emzeat commented 6 months ago

Please check 2da5cbb3124f4de5c221992e7d600a2e4e805161 available on latest dev.

barracuda156 commented 6 months ago

@emzeat Thank you for the update! From 2da5cbb3124f4de5c221992e7d600a2e4e805161 I still get these:

/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_group.cpp: In member function 'virtual bool xdispatch::libdispatch::group_impl::wait(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_group.cpp:66:61: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   66 |           DISPATCH_TIME_NOW, std::int64_t(timeout.count() * NSEC_PER_MSEC));
      |                                                             ^~~~~~~~~~~~~
      |                                                             NSEC_PER_USEC
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_group.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_queue.cpp: In member function 'virtual void xdispatch::libdispatch::queue_impl::after(std::chrono::milliseconds, const xdispatch::operation_ptr&)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_queue.cpp:65:59: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   65 |           DISPATCH_TIME_NOW, std::int64_t(delay.count() * NSEC_PER_MSEC));
      |                                                           ^~~~~~~~~~~~~
      |                                                           NSEC_PER_USEC
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_queue.cpp.o] Error 1
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::interval(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_timer.cpp:56:41: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   56 |         m_interval = interval.count() * NSEC_PER_MSEC;
      |                                         ^~~~~~~~~~~~~
      |                                         NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::latency(xdispatch::timer_precision)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_timer.cpp:69:23: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   69 |                   5 * NSEC_PER_MSEC; // NOLINT(readability-magic-numbers)
      |                       ^~~~~~~~~~~~~
      |                       NSEC_PER_USEC
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_timer.cpp: In member function 'virtual void xdispatch::libdispatch::timer_impl::resume(std::chrono::milliseconds)':
/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/xdispatch2-2da5cbb3124f4de5c221992e7d600a2e4e805161/src/libdispatch/libdispatch_timer.cpp:97:63: error: 'NSEC_PER_MSEC' was not declared in this scope; did you mean 'NSEC_PER_USEC'?
   97 |               DISPATCH_TIME_NOW, std::int64_t(delay.count() * NSEC_PER_MSEC));
      |                                                               ^~~~~~~~~~~~~
      |                                                               NSEC_PER_USEC
make[2]: *** [CMakeFiles/xdispatch.dir/src/libdispatch/libdispatch_timer.cpp.o] Error 1

This is because it exists only in 10.7+: https://developer.apple.com/documentation/dispatch/nsec_per_msec

barracuda156 commented 6 months ago

Could we address NSEC_PER_MSEC issue in some way?

emzeat commented 6 months ago

Well you simply need to add your own definition of the constant, see #6

barracuda156 commented 6 months ago

@emzeat The build is now fixed. Thanks you!

Benchmarks seem to pass, but report 0 nsec per operation. Is it expected?

36-142% cd /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/build
36-142% sh /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/build/bin/xdispatch2_benchmarks.sh 
Running in /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/build/bin

BENCHMARK SERIAL QUEUES
=======================
Running test 'libdispatch__cxx_benchmark_serial_queue'...
    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS
Running test 'naive__cxx_benchmark_serial_queue'...
    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS

   MUnit Test Framework with independent processes
   (c) 2011 MLBA

 ! Test (qt5__cxx_benchmark_serial_queue) does not exist

BENCHMARK GLOBAL QUEUES
=======================
Running test 'libdispatch__cxx_benchmark_global_queue'...
    -> Dispatched 99868 operations, 0 nsec per operation
    -> Executed 99868 operations, 0 nsec per operation
    PASS
Running test 'naive__cxx_benchmark_global_queue'...
    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS

   MUnit Test Framework with independent processes
   (c) 2011 MLBA

 ! Test (qt5__cxx_benchmark_global_queue) does not exist

BENCHMARK GROUPS
================
Running test 'libdispatch__cxx_benchmark_group'...
    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 99834 operations, 0 nsec per operation
    PASS
Running test 'naive__cxx_benchmark_group'...
    -> Dispatched 100000 operations, 0 nsec per operation
    -> Executed 100000 operations, 0 nsec per operation
    PASS

   MUnit Test Framework with independent processes
   (c) 2011 MLBA

 ! Test (qt5__cxx_benchmark_group) does not exist

Tests either freeze and do nothing or maybe take forever to run. At least after some waiting no change from here:

36-142% /opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_devel_xdispatch2-devel/xdispatch2-devel/work/build/bin/xdispatch2_tests 

   MUnit Test Framework with independent processes
   (c) 2011 MLBA

Running all Tests
==================================
(1) Running test 'libdispatch__cxx_dispatch_group'...
    -> sleeping...
    -> sleeping...
    -> sleeping...
    -> done.
    -> done.
    -> done.

I need the PowerMac for other tasks now, so perhaps gonna postpone a bit until I check this on Intel (where I can use macOS native libdispatch instead of my custom build I use on ppc).

emzeat commented 6 months ago

You are welcome.

You new findings seem special to your build, possibly related to the resolution of the chrono clocks on your system.

I am afraid that's something you would need to debug on your own.

As always I'd be happy to review any PR's - just please open a separate issue in case you intend to address this.

aeiouaeiouaeiouaeiouaeiouaeiou commented 6 months ago

For the missing dispatch_queue_attr_make_with_qos_class function there will be a feature test required in CMakeLists.txt:40.

@emzeat It's not clear how this test affects function detection, since its call is wrapped in the DISPATCH_QUEUE_SERIAL macro. The problem is that DISPATCH_QUEUE_SERIAL is available in macOS 10.7+, while dispatch_queue_attr_make_with_qos_class is only available in macOS 10.10 and newer. I'm thinking of additionally wrapping the detection of these functions via AvailabilityMacros.h, but I'm not sure if that would break cross-platform compatibility.

barracuda156 commented 6 months ago

@aeiouaeiouaeiouaeiouaeiouaeiou As long as AvailabilityMacros.h stuff is included only for Apple, it is safe. (And it should always be done that way, unless the code is exclusive to macOS.)

emzeat commented 6 months ago

@aeiouaeiouaeiouaeiouaeiouaeiou adding a feature test is fine but let's do it at configure time do features are fixed.

emzeat commented 6 months ago

Note that the compatibility fixes discussed here have been implemented by now so please open a new issue if needed