summaryrefslogtreecommitdiff
path: root/tests/mutex5.c
diff options
context:
space:
mode:
authorrpj <rpj>2005-03-16 01:36:11 +0000
committerrpj <rpj>2005-03-16 01:36:11 +0000
commite74acb9f56d1a46ba56e007352c2170c835ecb48 (patch)
treeabfbbf2f9a33a2f1192433aa5ba571bc02f9e08e /tests/mutex5.c
parent9b477bedafd2450735b78cdedc7af5e090aa8934 (diff)
Diffstat (limited to 'tests/mutex5.c')
-rw-r--r--tests/mutex5.c18
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);