Handle void * conversions in FreeBSD/x86 native code to fix C++ build.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-inferior.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include <string.h>
5 #include <pthread.h>
6
7 #define CHUNK_SIZE 16000 /* same as findcmd.c's */
8 #define BUF_SIZE (2 * CHUNK_SIZE) /* at least two chunks */
9 #define NUMTH 8
10
11 int8_t int8_search_buf[100];
12 int16_t int16_search_buf[100];
13 int32_t int32_search_buf[100];
14 int64_t int64_search_buf[100];
15
16 static char *search_buf;
17 static int search_buf_size;
18
19
20 int f2 (int a)
21 {
22 /* We use a `char[]' type below rather than the typical `char *'
23 to make sure that `str' gets allocated on the stack. Otherwise,
24 the compiler may place the "hello, testsuite" string inside
25 a read-only section, preventing us from over-writing it from GDB. */
26 char str[] = "hello, testsuite";
27
28 puts (str); /* Break here. */
29
30 return ++a;
31 }
32
33 int f1 (int a, int b)
34 {
35 return f2(a) + b;
36 }
37
38 static void
39 init_bufs ()
40 {
41 search_buf_size = BUF_SIZE;
42 search_buf = malloc (search_buf_size);
43 if (search_buf == NULL)
44 exit (1);
45 memset (search_buf, 'x', search_buf_size);
46 }
47
48 static void *
49 thread (void *param)
50 {
51 pthread_barrier_t *barrier = (pthread_barrier_t *) param;
52
53 pthread_barrier_wait (barrier);
54
55 return param;
56 }
57
58 static void
59 check_threads (pthread_barrier_t *barrier)
60 {
61 pthread_barrier_wait (barrier);
62 }
63
64 extern int
65 test_threads (void)
66 {
67 pthread_t threads[NUMTH];
68 pthread_barrier_t barrier;
69 int i;
70
71 pthread_barrier_init (&barrier, NULL, NUMTH + 1);
72
73 for (i = 0; i < NUMTH; ++i)
74 pthread_create (&threads[i], NULL, thread, &barrier);
75
76 check_threads (&barrier);
77
78 for (i = 0; i < NUMTH; ++i)
79 pthread_join (threads[i], NULL);
80
81 pthread_barrier_destroy (&barrier);
82
83 return 0;
84 }
85
86 int main (int argc, char *argv[])
87 {
88 test_threads ();
89 init_bufs ();
90
91 return f1 (1, 2);
92 }
This page took 0.032175 seconds and 4 git commands to generate.