diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index b5c1b23e527164b5a7380d063b98602a049dca38..98ede70f23c05d843035bd6a522ea64f35c0cdf0 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2808,6 +2808,9 @@ both scalar and vector modes.
 @subsubsection Environment attributes
 
 @table @code
+@item alarm
+Target supports @code{alarm}.
+
 @item c
 The language for the compiler under test is C.
 
diff --git a/gcc/testsuite/gcc.dg/pr116906-1.c b/gcc/testsuite/gcc.dg/pr116906-1.c
index 27b1fdae02bf843807cdf9274c1971401c13feac..7187507a60d116dee3252389d630abb01f7bd736 100644
--- a/gcc/testsuite/gcc.dg/pr116906-1.c
+++ b/gcc/testsuite/gcc.dg/pr116906-1.c
@@ -1,4 +1,5 @@
-/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
+/* { dg-require-effective-target alarm } */
+/* { dg-require-effective-target signal } */
 /* { dg-options "-O2" } */
 
 #include <stdint.h>
diff --git a/gcc/testsuite/gcc.dg/pr116906-2.c b/gcc/testsuite/gcc.dg/pr116906-2.c
index 3478771678ce242442723cb99dd36119ad862ebe..41a352bf8370949f9f16ba3763131a1b9c72bdcd 100644
--- a/gcc/testsuite/gcc.dg/pr116906-2.c
+++ b/gcc/testsuite/gcc.dg/pr116906-2.c
@@ -1,4 +1,5 @@
-/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
+/* { dg-require-effective-target alarm } */
+/* { dg-require-effective-target signal } */
 /* { dg-options "-O2 -fno-tree-ch" } */
 
 #include <unistd.h>
diff --git a/gcc/testsuite/gcc.dg/pr78185.c b/gcc/testsuite/gcc.dg/pr78185.c
index d7781b2080fb3a2387765dc6ad2b6091e90971f0..ada8b1b9f90773814b1c0a0337d2d4b184b64bc4 100644
--- a/gcc/testsuite/gcc.dg/pr78185.c
+++ b/gcc/testsuite/gcc.dg/pr78185.c
@@ -1,4 +1,5 @@
-/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
+/* { dg-require-effective-target alarm } */
+/* { dg-require-effective-target signal } */
 /* { dg-options "-O" } */
 
 #include <unistd.h>
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145inf.c b/gcc/testsuite/gcc.dg/vect/pr101145inf.c
index aa598875aa599585506f9845dbddcaaf7b7cd868..70aea94b6e0ba1c0de928f1ffeb9579ed7065684 100644
--- a/gcc/testsuite/gcc.dg/vect/pr101145inf.c
+++ b/gcc/testsuite/gcc.dg/vect/pr101145inf.c
@@ -1,3 +1,4 @@
+/* { dg-require-effective-target alarm } */
 /* { dg-require-effective-target signal } */
 /* { dg-additional-options "-O3" } */
 #include <limits.h>
diff --git a/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c b/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c
index 0465788c3ccaf2ee7deef3f088e34a6b47bc1cb9..fe008284e1d915f27c18e3fb7d1406769079db68 100644
--- a/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c
+++ b/gcc/testsuite/gcc.dg/vect/pr101145inf_1.c
@@ -1,3 +1,4 @@
+/* { dg-require-effective-target alarm } */
 /* { dg-require-effective-target signal } */
 /* { dg-additional-options "-O3" } */
 #include <limits.h>
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 1785a9d61500852481e30cfb39ea80dea502103b..9ad1e1965bbd10de537a21d34acc4bd9e8153d65 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -14271,3 +14271,30 @@ proc add_options_for_nvptx_alloca_ptx { flags } {
 
     return $flags
 }
+
+# Return true if alarm is supported on the target.
+
+proc check_effective_target_alarm { } {
+    if { ![check_effective_target_signal] } {
+	return 0
+    }
+
+    return [check_no_compiler_messages alarm executable {
+	#include <signal.h>
+	#include <stdlib.h>
+	#include <unistd.h>
+	void do_exit(int i) { exit (0); }
+	int main (void) { 
+	  struct sigaction s;
+	  sigemptyset (&s.sa_mask);
+	  s.sa_handler = exit;
+	  s.sa_flags = 0;
+	  sigaction (SIGALRM, &s, NULL);
+	  alarm (1);
+
+	  /* Infinite loop to simulate work...  */
+	  while (1);
+	  abort ();
+	}
+    }]
+}