Re: [PATCH 1/2] testsuite: New effective-target sleep

Hans-Peter Nilsson <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
> From: Mike Stump <[email protected]>
> Date: Thu, 23 Apr 2026 19:23:27 -0700

> On Apr 23, 2026, at 6:55 PM, Hans-Peter Nilsson <[email protected]> wrote:
> > 
> > See also PR libfortran/125005.  Ok for trunk and gcc-16?
> 
> Ok.
> 
> > libgfortran calls sleep, which is not available on all targets.
> > 
> > gcc:
> > 	* doc/sourcebuild.texi (Effective-Target Keywords): Document 'sleep'.
> > 
> > gcc/testsuite:
> > 	* lib/target-supports.exp (check_effective_target_sleep): New.
> 

Thanks!

Though after posting, I noticed that version had a placement
typo: I put the "sleep" entry right after "alarm", before
"c" (it's kind-of related to alarm).  I moved it to a
"better" position regarding alphabetization as per below as
obvious: committed.

The list has some stray entries or non-linear sequences, but
at least I didn't introduce any more out-of-order terms.

Tested for cris-elf with the-other-patch (awaiting review)
and sanity-checked on host x86-linux and viewed the
resulting gccint.info.

brgds, H-P

-- >8 --
From: Hans-Peter Nilsson <[email protected]>
Subject: [PATCH 1/2] testsuite: New effective-target sleep

libgfortran calls sleep, which is not available on all targets.

gcc:
	* doc/sourcebuild.texi (Effective-Target Keywords): Document 'sleep'.

gcc/testsuite:
	* lib/target-supports.exp (check_effective_target_sleep): New.
---
 gcc/doc/sourcebuild.texi              |  3 +++
 gcc/testsuite/lib/target-supports.exp | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 3bccb1384d9f..0bfcb96814d8 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2936,6 +2936,9 @@ Target can compile using @code{pthread.h} with no errors or warnings.
 @item pthread_h
 Target has @code{pthread.h}.
 
+@item sleep
+Target supports @code{sleep}.
+
 @item sockets
 Target can compile using @code{sys/socket.h} with no errors or warnings.
 
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index e7165e2e1b8c..bf00572e2bc6 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -14823,6 +14823,17 @@ proc check_effective_target_alarm { } {
     }]
 }
 
+# Return true if sleep is supported on the target.
+
+proc check_effective_target_sleep { } {
+    return [check_no_compiler_messages sleep executable {
+	#include <unistd.h>
+	int main (void) {
+	  sleep (1);
+	}
+    }]
+}
+
 # Return true if a speculation barrier is defined on the target.
 proc check_effective_target_speculation_barrier_defined { } {
     return [check_no_compiler_messages speculation_barrier_defined assembly {
-- 
2.30.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.