there was an #include directive missing
[openmpi-llc.git] / test / threads / opal_thread.c
blobe3e4dddbcc738136c5c0e86e1e99e55a99c715e2
1 #include "ompi_config.h"
3 #include <stdio.h>
5 #include "support.h"
6 #include "opal/constants.h"
7 #include "opal/threads/threads.h"
8 #include "opal/sys/atomic.h"
11 #if !OMPI_HAVE_THREAD_SUPPORT
13 /* If we don't have thread support, there's no point in running this
14 test */
16 int main(int argc, char *argv[])
18 printf("OMPI was compiled without thread support -- skipping this test\n");
19 return 77;
22 #else
24 /* Only have the body of this test if we have thread support */
26 static volatile int count = 0;
29 static void* thr1_run(opal_object_t* obj)
31 opal_atomic_add(&count, 1);
32 return NULL;
35 static void* thr2_run(opal_object_t* obj)
37 opal_atomic_add(&count, 2);
38 return NULL;
41 int main(int argc, char** argv)
43 int rc;
44 opal_thread_t thr1;
45 opal_thread_t thr2;
47 test_init("opal_thread_t");
49 OBJ_CONSTRUCT(&thr1, opal_thread_t);
50 OBJ_CONSTRUCT(&thr2, opal_thread_t);
52 thr1.t_run = thr1_run;
53 thr2.t_run = thr2_run;
55 rc = opal_thread_start(&thr1);
56 test_verify_int(OPAL_SUCCESS, rc);
58 rc = opal_thread_start(&thr2);
59 test_verify_int(OPAL_SUCCESS, rc);
61 rc = opal_thread_join(&thr1, NULL);
62 test_verify_int(OPAL_SUCCESS, rc);
64 rc = opal_thread_join(&thr2, NULL);
65 test_verify_int(OPAL_SUCCESS, rc);
67 test_verify_int(3, count);
68 return test_finalize();
71 #endif /* OMPI_HAVE_THREAD_SUPPORT */