|
1 |
| -#include "threads.h" |
2 | 1 | #include "pthread.h"
|
| 2 | +#include "threads.h" |
3 | 3 |
|
4 |
| -thrd_t g1; // COMPLIANT |
| 4 | +thrd_t g1; // COMPLIANT |
5 | 5 | pthread_t g2; // COMPLIANT
|
6 |
| -thrd_t g3[10]; // COMPLIANT |
7 |
| -pthread_t g4[10]; // COMPLIANT |
8 | 6 |
|
9 |
| -struct { |
10 |
| - thrd_t m1; // COMPLIANT |
11 |
| - pthread_t m2; // COMPLIANT |
12 |
| -} g7; |
13 |
| - |
14 |
| -void* pthread_func(void* arg); |
15 |
| -int thrd_func(void* arg); |
| 7 | +void *pthread_func(void *arg); |
| 8 | +int thrd_func(void *arg); |
16 | 9 |
|
17 | 10 | void make_threads_called_from_main(void);
|
18 | 11 | void func_called_from_main(void);
|
19 | 12 | void make_threads_called_from_func_called_from_main(void);
|
20 | 13 | void make_threads_called_from_main_pthread_thrd(void);
|
21 | 14 |
|
22 | 15 | void main() {
|
23 |
| - // Main starting top level threads -- ok. |
24 |
| - thrd_create(&g1, &thrd_func, NULL); // COMPLIANT |
| 16 | + thrd_create(&g1, &thrd_func, NULL); // COMPLIANT |
25 | 17 | pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT
|
26 | 18 |
|
27 |
| - // Starting thread in pool -- ok. |
28 |
| - thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT |
29 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT |
| 19 | + thrd_create(&g1, &thrd_func, NULL); // COMPLIANT |
| 20 | + pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT |
30 | 21 |
|
31 | 22 | make_threads_called_from_main();
|
32 | 23 | func_called_from_main();
|
33 | 24 | make_threads_called_from_main_pthread_thrd();
|
34 | 25 | }
|
35 | 26 |
|
36 | 27 | void make_threads_called_from_main() {
|
37 |
| - thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT |
38 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT |
| 28 | + thrd_create(&g1, &thrd_func, NULL); // COMPLIANT |
| 29 | + pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT |
39 | 30 | }
|
40 | 31 |
|
41 | 32 | void func_called_from_main() {
|
42 |
| - make_threads_called_from_func_called_from_main(); |
| 33 | + make_threads_called_from_func_called_from_main(); |
43 | 34 | }
|
44 | 35 |
|
45 | 36 | void make_threads_called_from_func_called_from_main() {
|
46 |
| - thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT |
47 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT |
| 37 | + thrd_create(&g1, &thrd_func, NULL); // COMPLIANT |
| 38 | + pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT |
48 | 39 | }
|
49 | 40 |
|
50 | 41 | void make_threads_called_from_pthread_func(void);
|
51 | 42 | void make_threads_called_from_thrd_func(void);
|
52 | 43 | void func_called_from_pthread_thrd(void);
|
53 | 44 | void make_threads_called_from_func_called_from_pthread_thrd(void);
|
54 | 45 |
|
55 |
| -void* pthread_func(void* arg) { |
56 |
| - thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT |
57 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT |
| 46 | +void *pthread_func(void *arg) { |
| 47 | + thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT |
| 48 | + pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT |
58 | 49 |
|
59 | 50 | make_threads_called_from_pthread_func();
|
60 | 51 | func_called_from_pthread_thrd();
|
61 | 52 | make_threads_called_from_main_pthread_thrd();
|
62 | 53 | }
|
63 | 54 |
|
64 |
| -int thrd_func(void* arg) { |
65 |
| - thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT |
66 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT |
| 55 | +int thrd_func(void *arg) { |
| 56 | + thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT |
| 57 | + pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT |
67 | 58 |
|
68 | 59 | make_threads_called_from_thrd_func();
|
69 | 60 | func_called_from_pthread_thrd();
|
70 | 61 | make_threads_called_from_main_pthread_thrd();
|
71 | 62 | }
|
72 | 63 |
|
73 | 64 | void make_threads_called_from_thrd_func(void) {
|
74 |
| - thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT |
75 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT |
| 65 | + thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT |
| 66 | + pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT |
76 | 67 | }
|
77 | 68 |
|
78 | 69 | void func_called_from_pthread_thrd(void) {
|
79 |
| - make_threads_called_from_func_called_from_pthread_thrd(); |
| 70 | + make_threads_called_from_func_called_from_pthread_thrd(); |
80 | 71 | }
|
81 | 72 |
|
82 | 73 | void make_threads_called_from_func_called_from_pthread_thrd(void) {
|
83 |
| - thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT |
84 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT |
| 74 | + thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT |
| 75 | + pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT |
85 | 76 | }
|
86 | 77 |
|
87 | 78 | void make_threads_called_from_main_pthread_thrd() {
|
88 |
| - thrd_create(&g3[0], &thrd_func, NULL); // NON-COMPLIANT |
89 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // NON-COMPLIANT |
| 79 | + thrd_create(&g1, &thrd_func, NULL); // NON-COMPLIANT |
| 80 | + pthread_create(&g2, NULL, &pthread_func, NULL); // NON-COMPLIANT |
90 | 81 | }
|
91 | 82 |
|
92 | 83 | void make_threads_not_called_by_anyone() {
|
93 |
| - thrd_create(&g3[0], &thrd_func, NULL); // COMPLIANT |
94 |
| - pthread_create(&g4[0], NULL, &pthread_func, NULL); // COMPLIANT |
| 84 | + thrd_create(&g1, &thrd_func, NULL); // COMPLIANT |
| 85 | + pthread_create(&g2, NULL, &pthread_func, NULL); // COMPLIANT |
95 | 86 | }
|
0 commit comments