summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrpj <rpj>2002-02-02 23:15:28 +0000
committerrpj <rpj>2002-02-02 23:15:28 +0000
commit4a72430d821b96add23846980d07f5a01059029d (patch)
tree6601b116e591db28feaed15a92ae46bfed8197da /tests
parent6a65a568fa4d9515265842c8bcf11a7449f3c325 (diff)
* cancel.c: Rearranged some code and introduced checks
to disable cancelation at the start of a thread's cancelation run to prevent double cancelation. The main problem arises if a thread is canceling and then receives a subsequent async cancel request. * private.c: Likewise. * condvar.c: Place pragmas around cleanup_push/pop to turn off inline optimisation (/Obn where n>0 - MSVC only). Various optimisation switches in MSVC turn this on, which interferes with the way that cleanup handlers are run in C++ EH and SEH code. Application code compiled with inline optimisation must also wrap cleanup_push/pop blocks with the pragmas, e.g. #pragma inline_depth(0) pthread_cleanup_push(...) ... pthread_cleanup_pop(...) #pragma inline_depth(8) * rwlock.c: Likewise. * mutex.c: Remove attempts to inline some functions. * signal.c: Modify misleading comment. tests/ * mutex8: New test. * mutex8n: New test. * mutex8e: New test. * mutex8r: New test. * cancel6a: New test. * cancel6d: New test. * cleanup0.c: Add pragmas for inline optimisation control. * cleanup1.c: Add pragmas for inline optimisation control. * cleanup2.c: Add pragmas for inline optimisation control. * cleanup3.c: Add pragmas for inline optimisation control. * condvar7.c: Add pragmas for inline optimisation control. * condvar8.c: Add pragmas for inline optimisation control. * condvar9.c: Add pragmas for inline optimisation control.
Diffstat (limited to 'tests')
-rw-r--r--tests/ChangeLog16
-rw-r--r--tests/GNUmakefile18
-rw-r--r--tests/Makefile14
-rw-r--r--tests/cleanup0.c8
-rw-r--r--tests/cleanup1.c7
-rw-r--r--tests/cleanup2.c6
-rw-r--r--tests/cleanup3.c6
-rw-r--r--tests/condvar7.c6
-rw-r--r--tests/condvar8.c12
-rw-r--r--tests/condvar9.c12
10 files changed, 90 insertions, 15 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 91f823e..3e3ee9c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,19 @@
+2002-02-02 Ross Johnson <rpj@special.ise.canberra.edu.au>
+
+ * mutex8: New test.
+ * mutex8n: New test.
+ * mutex8e: New test.
+ * mutex8r: New test.
+ * cancel6a: New test.
+ * cancel6d: New test.
+ * cleanup0.c: Add pragmas for inline optimisation control.
+ * cleanup1.c: Add pragmas for inline optimisation control.
+ * cleanup2.c: Add pragmas for inline optimisation control.
+ * cleanup3.c: Add pragmas for inline optimisation control.
+ * condvar7.c: Add pragmas for inline optimisation control.
+ * condvar8.c: Add pragmas for inline optimisation control.
+ * condvar9.c: Add pragmas for inline optimisation control.
+
2002-01-30 Ross Johnson <rpj@special.ise.canberra.edu.au>
* cleanup1.c (): Must be declared __cdecl when compiled
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
index 0bf4102..c18e444 100644
--- a/tests/GNUmakefile
+++ b/tests/GNUmakefile
@@ -16,11 +16,11 @@ MAKE = make
#
# Mingw32
#
-GLANG = c++
+GLANG = c++
CC = gcc
XXCFLAGS =
-#CFLAGS = -g -O0 -mthreads -UNDEBUG -Wall -x $(GLANG)
-#CFLAGS = -O3 -mthreads -UNDEBUG -Wall -x $(GLANG)
+#CFLAGS = -g -O0 -mthreads -UNDEBUG -Wall -x $(GLANG)
+#CFLAGS = -O3 -mthreads -UNDEBUG -Wall -x $(GLANG)
CFLAGS = -g -O0 -UNDEBUG -Wall $(XXCFLAGS)
BUILD_DIR = ..
INCLUDES = -I.
@@ -40,13 +40,13 @@ TESTS = loadfree \
condvar1 condvar2 condvar2_1 exit1 create1 equal1 \
exit2 exit3 \
join0 join1 join2 mutex2 mutex3 mutex4 mutex6 mutex6n mutex6e mutex6r \
- mutex7 mutex7n mutex7e mutex7r \
+ mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \
count1 once1 tsd1 self2 cancel1 cancel2 eyal1 \
condvar3 condvar3_1 condvar3_2 condvar3_3 \
condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \
errno1 \
rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 \
- context1 cancel3 cancel4 cancel5 \
+ context1 cancel3 cancel4 cancel5 cancel6a cancel6d \
cleanup0 cleanup1 cleanup2 cleanup3 \
priority1 priority2 inherit1 \
spin1 spin2 spin3 spin4 \
@@ -65,7 +65,7 @@ default:
@ $(ECHO) nmake clean GC (to test using GC dll with C (no EH) applications)
@ $(ECHO) nmake clean GCX (to test using GC dll with C++ (EH) applications)
@ $(ECHO) nmake clean GCE-bench (to benchtest using GNU C dll with C++ exception handling)
- @ $(ECHO) nmake clean GC-bench (to benchtest using GNU C dll with C cleanup code)
+ @ $(ECHO) nmake clean GC-bench (to benchtest using GNU C dll with C cleanup code)
auto:
@ $(MAKE) clean GCE
@@ -109,6 +109,8 @@ cancel2_1.pass: cancel2.pass
cancel3.pass: context1.pass
cancel4.pass: cancel3.pass
cancel5.pass: cancel3.pass
+cancel6a.pass: cancel3.pass
+cancel6d.pass: cancel3.pass
cleanup0.pass: cancel5.pass
cleanup1.pass: cleanup0.pass
cleanup2.pass: cleanup1.pass
@@ -159,6 +161,10 @@ mutex7.pass: mutex6.pass
mutex7n.pass: mutex6n.pass
mutex7e.pass: mutex6e.pass
mutex7r.pass: mutex6r.pass
+mutex8.pass: mutex7.pass
+mutex8n.pass: mutex7n.pass
+mutex8e.pass: mutex7e.pass
+mutex8r.pass: mutex7r.pass
once1.pass: create1.pass
priority1.pass: join1.pass
priority2.pass: priority1.pass
diff --git a/tests/Makefile b/tests/Makefile
index 74c9b8b..5f160cb 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -10,6 +10,8 @@ ECHO = @echo
CPHDR = pthread.h semaphore.h sched.h
+OPTIM = /O2
+
# C++ Exceptions
VCEFLAGS = /GX /TP /DPtW32NoCatchWarn /D__CLEANUP_CXX
VCELIB = pthreadVCE.lib
@@ -25,7 +27,7 @@ VCDLL = pthreadVC.dll
# C++ Exceptions in application - using VC version of pthreads dll
VCXFLAGS = /GX /TP /D__CLEANUP_C
-CFLAGS= /W3 /WX /MT /nologo /Yd /Zi -D_WIN32_WINNT=0x400
+CFLAGS= $(OPTIM) /W3 /WX /MT /nologo /Yd /Zi -D_WIN32_WINNT=0x400
LFLAGS= /INCREMENTAL:NO
INCLUDES=-I.
BUILD_DIR=..
@@ -47,6 +49,7 @@ PASSES= loadfree.pass \
join0.pass join1.pass join2.pass \
mutex4.pass mutex6.pass mutex6n.pass mutex6e.pass mutex6r.pass \
mutex7.pass mutex7n.pass mutex7e.pass mutex7r.pass \
+ mutex8.pass mutex8n.pass mutex8e.pass mutex8r.pass \
count1.pass once1.pass tsd1.pass \
self2.pass \
cancel1.pass cancel2.pass \
@@ -57,7 +60,7 @@ PASSES= loadfree.pass \
errno1.pass \
rwlock1.pass rwlock2.pass rwlock3.pass rwlock4.pass rwlock5.pass rwlock6.pass rwlock7.pass \
context1.pass \
- cancel3.pass cancel4.pass cancel5.pass \
+ cancel3.pass cancel4.pass cancel5.pass cancel6a.pass cancel6d.pass \
cleanup0.pass cleanup1.pass cleanup2.pass cleanup3.pass \
priority1.pass priority2.pass inherit1.pass \
spin1.pass spin2.pass spin3.pass spin4.pass \
@@ -152,6 +155,7 @@ clean:
- $(RM) *.obj
- $(RM) *.pdb
- $(RM) *.o
+ - $(RM) *.asm
- $(RM) *.exe
- $(RM) *.pass
- $(RM) *.bench
@@ -171,6 +175,8 @@ cancel2.pass: cancel1.pass
cancel3.pass: context1.pass
cancel4.pass: cancel3.pass
cancel5.pass: cancel3.pass
+cancel6a.pass: cancel3.pass
+cancel6d.pass: cancel3.pass
cleanup0.pass: cancel5.pass
cleanup1.pass: cleanup0.pass
cleanup2.pass: cleanup1.pass
@@ -221,6 +227,10 @@ mutex7.pass: mutex6.pass
mutex7n.pass: mutex6n.pass
mutex7e.pass: mutex6e.pass
mutex7r.pass: mutex6r.pass
+mutex8.pass: mutex7.pass
+mutex8n.pass: mutex7n.pass
+mutex8e.pass: mutex7e.pass
+mutex8r.pass: mutex7r.pass
once1.pass: create1.pass
priority1.pass: join1.pass
priority2.pass: priority1.pass
diff --git a/tests/cleanup0.c b/tests/cleanup0.c
index ef7c6bb..9cd9c5c 100644
--- a/tests/cleanup0.c
+++ b/tests/cleanup0.c
@@ -109,11 +109,17 @@ mythread(void * arg)
assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
+#ifdef _MSC_VER
+#pragma inline_depth(0)
+#endif
pthread_cleanup_push(increment_pop_count, (void *) &pop_count);
Sleep(100);
pthread_cleanup_pop(1);
+#ifdef _MSC_VER
+#pragma inline_depth(8)
+#endif
return (void *) result;
}
@@ -176,7 +182,7 @@ main()
fprintf(stderr, "Thread %d: started %d: result %d\n",
i,
threadbag[i].started,
- result);
+ result);
fflush(stderr);
}
failed = (failed || fail);
diff --git a/tests/cleanup1.c b/tests/cleanup1.c
index 2b2ffe4..52a67c7 100644
--- a/tests/cleanup1.c
+++ b/tests/cleanup1.c
@@ -89,6 +89,7 @@ static void
#ifdef __CLEANUP_C
__cdecl
#endif
+
increment_pop_count(void * arg)
{
int * c = (int *) arg;
@@ -112,6 +113,9 @@ mythread(void * arg)
assert(pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL) == 0);
+#ifdef _MSC_VER
+#pragma inline_depth(0)
+#endif
pthread_cleanup_push(increment_pop_count, (void *) &pop_count);
/*
* We don't have true async cancelation - it relies on the thread
@@ -123,6 +127,9 @@ mythread(void * arg)
Sleep(100);
pthread_cleanup_pop(0);
+#ifdef _MSC_VER
+#pragma inline_depth(8)
+#endif
return (void *) result;
}
diff --git a/tests/cleanup2.c b/tests/cleanup2.c
index 373275b..4d1fafe 100644
--- a/tests/cleanup2.c
+++ b/tests/cleanup2.c
@@ -103,11 +103,17 @@ mythread(void * arg)
assert(bag->started == 0);
bag->started = 1;
+#ifdef _MSC_VER
+#pragma inline_depth(0)
+#endif
pthread_cleanup_push(increment_pop_count, (void *) &pop_count);
sched_yield();
pthread_cleanup_pop(1);
+#ifdef _MSC_VER
+#pragma inline_depth(8)
+#endif
return (void *) result;
}
diff --git a/tests/cleanup3.c b/tests/cleanup3.c
index 0b88da1..2d44f79 100644
--- a/tests/cleanup3.c
+++ b/tests/cleanup3.c
@@ -104,6 +104,9 @@ mythread(void * arg)
assert(bag->started == 0);
bag->started = 1;
+#ifdef _MSC_VER
+#pragma inline_depth(0)
+#endif
pthread_cleanup_push(increment_pop_count, (void *) &pop_count);
sched_yield();
@@ -111,6 +114,9 @@ mythread(void * arg)
pop_count--;
pthread_cleanup_pop(0);
+#ifdef _MSC_VER
+#pragma inline_depth(8)
+#endif
return (void *) result;
}
diff --git a/tests/condvar7.c b/tests/condvar7.c
index 8eb5879..0e52c64 100644
--- a/tests/condvar7.c
+++ b/tests/condvar7.c
@@ -116,12 +116,18 @@ mythread(void * arg)
assert(pthread_mutex_lock(&cvthing.lock) == 0);
+#ifdef _MSC_VER
+#pragma inline_depth(0)
+#endif
pthread_cleanup_push(pthread_mutex_unlock, (void *) &cvthing.lock);
while (! (cvthing.shared > 0))
assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0);
pthread_cleanup_pop(0);
+#ifdef _MSC_VER
+#pragma inline_depth(8)
+#endif
assert(cvthing.shared > 0);
diff --git a/tests/condvar8.c b/tests/condvar8.c
index cef458a..6f2b458 100644
--- a/tests/condvar8.c
+++ b/tests/condvar8.c
@@ -116,12 +116,18 @@ mythread(void * arg)
assert(pthread_mutex_lock(&cvthing.lock) == 0);
+#ifdef _MSC_VER
+#pragma inline_depth(0)
+#endif
pthread_cleanup_push(pthread_mutex_unlock, (void *) &cvthing.lock);
while (! (cvthing.shared > 0))
assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0);
pthread_cleanup_pop(0);
+#ifdef _MSC_VER
+#pragma inline_depth(8)
+#endif
assert(cvthing.shared > 0);
@@ -211,9 +217,9 @@ main()
failed = !threadbag[i].started;
if (failed)
- {
- fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started);
- }
+ {
+ fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started);
+ }
}
/*
diff --git a/tests/condvar9.c b/tests/condvar9.c
index 48f4320..e06df17 100644
--- a/tests/condvar9.c
+++ b/tests/condvar9.c
@@ -121,12 +121,18 @@ mythread(void * arg)
* pthread_cond_timedwait is a cancelation point and we
* going to cancel one deliberately.
*/
+#ifdef _MSC_VER
+#pragma inline_depth(0)
+#endif
pthread_cleanup_push(pthread_mutex_unlock, (void *) &cvthing.lock);
while (! (cvthing.shared > 0))
assert(pthread_cond_timedwait(&cvthing.notbusy, &cvthing.lock, &abstime) == 0);
pthread_cleanup_pop(0);
+#ifdef _MSC_VER
+#pragma inline_depth(8)
+#endif
assert(cvthing.shared > 0);
@@ -218,9 +224,9 @@ main()
failed = !threadbag[i].started;
if (failed)
- {
- fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started);
- }
+ {
+ fprintf(stderr, "Thread %d: started %d\n", i, threadbag[i].started);
+ }
}
/*