diff options
Diffstat (limited to 'tests/mutex5.c')
-rw-r--r-- | tests/mutex5.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/mutex5.c b/tests/mutex5.c index a597892..a71f9d8 100644 --- a/tests/mutex5.c +++ b/tests/mutex5.c @@ -41,19 +41,23 @@ static pthread_mutexattr_t mxAttr; +/* Prevent optimiser from removing dead or obvious asserts. */ +int _optimiseFoil; +#define FOIL(x) (_optimiseFoil = x) + int main() { int mxType = -1; - assert(PTHREAD_MUTEX_DEFAULT == PTHREAD_MUTEX_NORMAL); - assert(PTHREAD_MUTEX_DEFAULT != PTHREAD_MUTEX_ERRORCHECK); - assert(PTHREAD_MUTEX_DEFAULT != PTHREAD_MUTEX_RECURSIVE); - assert(PTHREAD_MUTEX_RECURSIVE != PTHREAD_MUTEX_ERRORCHECK); + assert(FOIL(PTHREAD_MUTEX_DEFAULT) == PTHREAD_MUTEX_NORMAL); + assert(FOIL(PTHREAD_MUTEX_DEFAULT) != PTHREAD_MUTEX_ERRORCHECK); + assert(FOIL(PTHREAD_MUTEX_DEFAULT) != PTHREAD_MUTEX_RECURSIVE); + assert(FOIL(PTHREAD_MUTEX_RECURSIVE) != PTHREAD_MUTEX_ERRORCHECK); - assert(PTHREAD_MUTEX_NORMAL == PTHREAD_MUTEX_FAST_NP); - assert(PTHREAD_MUTEX_RECURSIVE == PTHREAD_MUTEX_RECURSIVE_NP); - assert(PTHREAD_MUTEX_ERRORCHECK == PTHREAD_MUTEX_ERRORCHECK_NP); + assert(FOIL(PTHREAD_MUTEX_NORMAL) == PTHREAD_MUTEX_FAST_NP); + assert(FOIL(PTHREAD_MUTEX_RECURSIVE) == PTHREAD_MUTEX_RECURSIVE_NP); + assert(FOIL(PTHREAD_MUTEX_ERRORCHECK) == PTHREAD_MUTEX_ERRORCHECK_NP); assert(pthread_mutexattr_init(&mxAttr) == 0); assert(pthread_mutexattr_gettype(&mxAttr, &mxType) == 0); |