// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
-// { dg-options "-pthread" }
-// { dg-do run { target *-*-linux-gnu } }
-// { dg-require-effective-target pthread }
+// { dg-do run }
+// { dg-additional-options "-pthread" { target pthread } }
+
+// Static init cannot detect recursion for gthreads targets without futexes
+// (and the futex case can only detect it if __libc_single_threaded==true).
+// { dg-skip-if "unsupported" { gthreads && { ! futex } } }
// PR libstdc++/96817
#include <exception>
#include <stdlib.h>
-#ifndef _GLIBCXX_HAVE_LINUX_FUTEX
-# error "This test requries futex support in the library"
-#endif
-
int init()
{
#if __has_include(<sys/single_threaded.h>)
// <http://www.gnu.org/licenses/>.
// { dg-do run { target c++11 } }
-// { dg-skip-if "" { pthread && { ! *-*-*linux* } } }
// { dg-additional-options "-pthread" { target pthread } }
+// Currently std::call_once is broken for gthreads targets without futexes:
+// { dg-skip-if "see PR 66146" { gthreads && { ! futex } } }
+
#include <mutex>
#include <cstdlib>
#include <testsuite_hooks.h>
}]
}
+# Return 1 if futex syscall is available
+proc check_effective_target_futex { } {
+ return [check_v3_target_prop_cached et_futex {
+ # Set up and compile a C++ test program that depends on tbb
+ set src futex[pid].cc
+ set exe futex[pid].x
+
+ set f [open $src "w"]
+ puts $f "#include <bits/c++config.h>"
+ puts $f "#if ! _GLIBCXX_HAVE_LINUX_FUTEX"
+ puts $f "# error No futex syscall available"
+ puts $f "#endif"
+ close $f
+
+ set lines [v3_target_compile $src /dev/null preprocess ""]
+ file delete $src
+
+ if [string match "" $lines] {
+ # No error message, preprocessing succeeded.
+ verbose "check_v3_futex: `1'" 2
+ return 1
+ }
+ verbose "check_v3_futex: `0'" 2
+ return 0
+ }]
+}
+
+# Return 1 if futex syscall is available
+proc check_effective_target_gthreads { } {
+ return [check_v3_target_gthreads_timed]
+}
+
set additional_prunes ""
if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \