| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-require-effective-target signal } */ |
| 3 |
/* { dg-require-effective-target alarm } */ |
| 4 |
/* { dg-options "-O2" } */ |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
#include <unistd.h> |
| 8 |
#include <signal.h> |
| 9 |
#include <stdlib.h> |
| 10 |
|
| 11 |
volatile int y; |
| 12 |
void __attribute__((noipa)) put(int x) |
| 13 |
{ |
| 14 |
if (y) |
| 15 |
__builtin_printf ("%i\n", x); |
| 16 |
} |
| 17 |
|
| 18 |
void __attribute__((noipa)) f(void) |
| 19 |
{ |
| 20 |
int counter = 0; |
| 21 |
while (1) { |
| 22 |
if (counter >= 2) continue; |
| 23 |
put (counter++); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
void do_exit (int i) |
| 28 |
{ |
| 29 |
exit (0); |
| 30 |
} |
| 31 |
|
| 32 |
int main() |
| 33 |
{ |
| 34 |
struct sigaction s; |
| 35 |
sigemptyset (&s.sa_mask); |
| 36 |
s.sa_handler = do_exit; |
| 37 |
s.sa_flags = 0; |
| 38 |
sigaction (SIGALRM, &s, NULL); |
| 39 |
alarm (1); |
| 40 |
f(); |
| 41 |
} |