1
1
openmpi/test/threads/ompi_thread.c
Jeff Squyres d324a7725c - Add #if protection around non-portable system .h files
- Add #include "ompi_config.h" to all .c files, and ensure that it's
  the first #included file
- remove a few useless #if HAVE_CONFIG_H checks

This commit was SVN r3229.
2004-10-20 01:03:09 +00:00

55 строки
1015 B
C

#include "ompi_config.h"
#include "support.h"
#include "include/constants.h"
#include "threads/thread.h"
#include "include/sys/atomic.h"
static volatile int count = 0;
static void* thr1_run(ompi_object_t* obj)
{
ompi_atomic_add_int(&count, 1);
return NULL;
}
static void* thr2_run(ompi_object_t* obj)
{
ompi_atomic_add_int(&count, 2);
return NULL;
}
int main(int argc, char** argv)
{
int rc;
ompi_thread_t thr1;
ompi_thread_t thr2;
test_init("ompi_thread_t");
OBJ_CONSTRUCT(&thr1, ompi_thread_t);
OBJ_CONSTRUCT(&thr2, ompi_thread_t);
thr1.t_run = thr1_run;
thr2.t_run = thr2_run;
rc = ompi_thread_start(&thr1);
test_verify_int(OMPI_SUCCESS, rc);
rc = ompi_thread_start(&thr2);
test_verify_int(OMPI_SUCCESS, rc);
rc = ompi_thread_join(&thr1, NULL);
test_verify_int(OMPI_SUCCESS, rc);
rc = ompi_thread_join(&thr2, NULL);
test_verify_int(OMPI_SUCCESS, rc);
test_verify_int(3, count);
return test_finalize();
}