Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gcc.dg/pr85388-2.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* { dg-do run { target { i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } } */ | |
2 /* { dg-require-effective-target cet } */ | |
3 /* { dg-require-effective-target split_stack } */ | |
4 /* { dg-require-effective-target pthread_h } */ | |
5 /* { dg-options "-pthread -fsplit-stack -fcf-protection" } */ | |
6 | |
7 #include <stdlib.h> | |
8 #include <pthread.h> | |
9 | |
10 /* Use a noinline function to ensure that the buffer is not removed | |
11 from the stack. */ | |
12 static void use_buffer (char *buf) __attribute__ ((noinline)); | |
13 static void | |
14 use_buffer (char *buf) | |
15 { | |
16 buf[0] = '\0'; | |
17 } | |
18 | |
19 /* Each recursive call uses 10,000 bytes. We call it 1000 times, | |
20 using a total of 10,000,000 bytes. If -fsplit-stack is not | |
21 working, that will overflow our stack limit. */ | |
22 | |
23 static void | |
24 down (int i) | |
25 { | |
26 char buf[10000]; | |
27 | |
28 if (i > 0) | |
29 { | |
30 use_buffer (buf); | |
31 down (i - 1); | |
32 } | |
33 } | |
34 | |
35 static void * | |
36 thread_routine (void *arg __attribute__ ((unused))) | |
37 { | |
38 down (1000); | |
39 return NULL; | |
40 } | |
41 | |
42 int | |
43 main (void) | |
44 { | |
45 int i; | |
46 pthread_t tid; | |
47 void *dummy; | |
48 | |
49 i = pthread_create (&tid, NULL, thread_routine, NULL); | |
50 if (i != 0) | |
51 abort (); | |
52 i = pthread_join (tid, &dummy); | |
53 if (i != 0) | |
54 abort (); | |
55 return 0; | |
56 } |