@subsubsection Environment attributes
@table @code
+@item alarm
+Target supports @code{alarm}.
+
@item c
The language for the compiler under test is C.
-/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
+/* { dg-require-effective-target alarm } */
+/* { dg-require-effective-target signal } */
/* { dg-options "-O2" } */
#include <stdint.h>
-/* { 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>
-/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
+/* { dg-require-effective-target alarm } */
+/* { dg-require-effective-target signal } */
/* { dg-options "-O" } */
#include <unistd.h>
+/* { dg-require-effective-target alarm } */
/* { dg-require-effective-target signal } */
/* { dg-additional-options "-O3" } */
#include <limits.h>
+/* { dg-require-effective-target alarm } */
/* { dg-require-effective-target signal } */
/* { dg-additional-options "-O3" } */
#include <limits.h>
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 ();
+ }
+ }]
+}