xref: /llvm-project/openmp/runtime/test/misc_bugs/omp__kmpc_fork_call_if.c (revision 2a57657d5571b097eb0070e6f26ad4954c0fd990)
1 // RUN: %libomp-compile && %t | FileCheck %s
2 
3 #include <stdio.h>
4 #include <omp.h>
5 
6 typedef int32_t kmp_int32;
7 typedef void *ident_t;
8 typedef void *kmpc_micro;
9 
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 extern void __kmpc_fork_call_if(ident_t *loc, kmp_int32 argc,
14                                 kmpc_micro microtask, kmp_int32 cond,
15                                 void *args);
16 #ifdef __cplusplus
17 }
18 #endif
19 
20 // Microtask function for parallel region
microtask(int * global_tid,int * bound_tid)21 void microtask(int *global_tid, int *bound_tid) {
22   // CHECK: PASS
23   if (omp_in_parallel()) {
24     printf("FAIL\n");
25   } else {
26     printf("PASS\n");
27   }
28 }
29 
main()30 int main() {
31   // Condition for parallelization (false in this case)
32   int cond = 0;
33   // Call __kmpc_fork_call_if
34   __kmpc_fork_call_if(NULL, 0, microtask, cond, NULL);
35   return 0;
36 }
37