diff --git a/.travis.yml b/.travis.yml index a6e571274..eeaee727b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,7 @@ matrix: # macOS with system compiler (clang) - os: osx compiler: clang - env: OOT=0 TEST=0 SDE=0 THR="none" CONF="auto" + env: OOT=0 TEST=1 SDE=0 THR="none" CONF="auto" # cortexa15 build and test (qemu) - os: linux compiler: arm-linux-gnueabihf-gcc diff --git a/testsuite/src/pthread_barrier.h b/testsuite/src/pthread_barrier.h new file mode 100644 index 000000000..31bd27a10 --- /dev/null +++ b/testsuite/src/pthread_barrier.h @@ -0,0 +1,68 @@ +#if !defined(_POSIX_BARRIERS) || (_POSIX_BARRIERS < 0) + +#ifndef PTHREAD_BARRIER_H_ +#define PTHREAD_BARRIER_H_ + +#include +#include + +typedef int pthread_barrierattr_t; +typedef struct +{ + pthread_mutex_t mutex; + pthread_cond_t cond; + int count; + int tripCount; +} pthread_barrier_t; + + +inline int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) +{ + if(count == 0) + { + errno = EINVAL; + return -1; + } + if(pthread_mutex_init(&barrier->mutex, 0) < 0) + { + return -1; + } + if(pthread_cond_init(&barrier->cond, 0) < 0) + { + pthread_mutex_destroy(&barrier->mutex); + return -1; + } + barrier->tripCount = count; + barrier->count = 0; + + return 0; +} + +inline int pthread_barrier_destroy(pthread_barrier_t *barrier) +{ + pthread_cond_destroy(&barrier->cond); + pthread_mutex_destroy(&barrier->mutex); + return 0; +} + +inline int pthread_barrier_wait(pthread_barrier_t *barrier) +{ + pthread_mutex_lock(&barrier->mutex); + ++(barrier->count); + if(barrier->count >= barrier->tripCount) + { + barrier->count = 0; + pthread_cond_broadcast(&barrier->cond); + pthread_mutex_unlock(&barrier->mutex); + return 1; + } + else + { + pthread_cond_wait(&barrier->cond, &(barrier->mutex)); + pthread_mutex_unlock(&barrier->mutex); + return 0; + } +} + +#endif // PTHREAD_BARRIER_H_ +#endif // _POSIX_BARRIERS diff --git a/testsuite/src/test_libblis.h b/testsuite/src/test_libblis.h index c0329377f..73880de74 100644 --- a/testsuite/src/test_libblis.h +++ b/testsuite/src/test_libblis.h @@ -54,6 +54,9 @@ // For pthreads API. #include +#if !defined(_POSIX_BARRIERS) || (_POSIX_BARRIERS < 0) +#include "pthread_barrier.h" +#endif // // --- Constants and types -----------------------------------------------------