summaryrefslogtreecommitdiff
path: root/tests/mutex5.c
diff options
context:
space:
mode:
authorrpj <rpj>2005-03-16 01:33:20 +0000
committerrpj <rpj>2005-03-16 01:33:20 +0000
commit37f6fe772e5779120d2ee372c5d51ff60b6801dc (patch)
treeb611e6b1c26e36a32e761962ab6693b02744c784 /tests/mutex5.c
parent3d32060783bcaf10f38ff6eef6fcf5711bfeada4 (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);