1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // UNSUPPORTED: libcpp-has-no-threads 10 // UNSUPPORTED: c++98, c++03, c++11 11 12 // This test requires the dylib support introduced in D68480 13 // XFAIL: with_system_cxx_lib=macosx10.15 14 // XFAIL: with_system_cxx_lib=macosx10.14 15 // XFAIL: with_system_cxx_lib=macosx10.13 16 // XFAIL: with_system_cxx_lib=macosx10.12 17 // XFAIL: with_system_cxx_lib=macosx10.11 18 // XFAIL: with_system_cxx_lib=macosx10.10 19 // XFAIL: with_system_cxx_lib=macosx10.9 20 21 // <semaphore> 22 23 #include <semaphore> 24 #include <chrono> 25 #include <thread> 26 27 #include "test_macros.h" 28 29 int main(int, char**) 30 { 31 std::binary_semaphore s(1); 32 33 auto l = [&](){ 34 for(int i = 0; i < 1024; ++i) { 35 s.acquire(); 36 std::this_thread::sleep_for(std::chrono::microseconds(1)); 37 s.release(); 38 } 39 }; 40 41 std::thread t(l); 42 l(); 43 44 t.join(); 45 46 return 0; 47 } 48