1// RUN: %libomp-compile && env OMP_WAIT_POLICY=active %libomp-run active
2// RUN: %libomp-compile && env OMP_WAIT_POLICY=passive %libomp-run passive
3//
4// OMP_WAIT_POLICY=active should imply blocktime == INT_MAX
5// i.e., threads spin-wait forever
6// OMP_WAIT_POLICY=passive should imply blocktime == 0
7// i.e., threads immediately sleep
8#include <stdio.h>
9#include <string.h>
10#include <limits.h>
11#include "omp_testsuite.h"
12
13void usage() {
14 fprintf(stderr, format: "usage: omp_wait_policy active|passive\n");
15}
16
17int main(int argc, char** argv)
18{
19 int blocktime, retval=1;
20 const char* env_var_value;
21
22 if (argc != 2) {
23 usage();
24 return 1;
25 }
26
27 blocktime = kmp_get_blocktime();
28
29 env_var_value = argv[1];
30 if (!strcmp(s1: env_var_value, s2: "active")) {
31 retval = (blocktime != INT_MAX);
32 } else if (!strcmp(s1: env_var_value, s2: "passive")) {
33 retval = (blocktime != 0);
34 } else {
35 usage();
36 retval = 1;
37 }
38
39 return retval;
40}
41

source code of openmp/runtime/test/env/omp_wait_policy.c