aboutsummaryrefslogtreecommitdiff
path: root/pthreads/tests/exception3.c
diff options
context:
space:
mode:
Diffstat (limited to 'pthreads/tests/exception3.c')
-rw-r--r--pthreads/tests/exception3.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/pthreads/tests/exception3.c b/pthreads/tests/exception3.c
index 65bcdbef3..3b9ec6fd9 100644
--- a/pthreads/tests/exception3.c
+++ b/pthreads/tests/exception3.c
@@ -6,10 +6,11 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2005 Pthreads-win32 contributors
- *
- * Contact Email: rpj@callisto.canberra.edu.au
- *
+ * Copyright(C) 1999,2012 Pthreads-win32 contributors
+ *
+ * Homepage1: http://sourceware.org/pthreads-win32/
+ * Homepage2: http://sourceforge.net/projects/pthreads4w/
+ *
* The current list of contributors is contained
* in the file CONTRIBUTORS included with the source
* code distribution. The list can also be seen at the
@@ -73,7 +74,13 @@
#include "test.h"
-#if defined(__cplusplus)
+/*
+ * Note: Due to a buggy C++ runtime in Visual Studio 2005, when we are
+ * built with /MD and an unhandled exception occurs, the runtime does not
+ * properly call the terminate handler specified by set_terminate().
+ */
+#if defined(__cplusplus) \
+ && !(defined(_MSC_VER) && _MSC_VER == 1400 && defined(_DLL) && !defined(_DEBUG))
#if defined(_MSC_VER)
# include <eh.h>
@@ -90,7 +97,7 @@
* Create NUMTHREADS threads in addition to the Main thread.
*/
enum {
- NUMTHREADS = 1
+ NUMTHREADS = 10
};
int caught = 0;
@@ -125,12 +132,24 @@ terminateFunction ()
exit(0);
}
+void
+wrongTerminateFunction ()
+{
+ fputs("This is not the termination routine that should have been called!\n", stderr);
+ exit(1);
+}
+
void *
exceptionedThread(void * arg)
{
int dummy = 0x1;
- (void) set_terminate(&terminateFunction);
+#if defined(PTW32_USES_SEPARATE_CRT) && (defined(__CLEANUP_CXX) || defined(__CLEANUP_SEH))
+ pthread_win32_set_terminate_np(&terminateFunction);
+ set_terminate(&wrongTerminateFunction);
+#else
+ set_terminate(&terminateFunction);
+#endif
throw dummy;
@@ -159,14 +178,12 @@ main()
assert(pthread_create(&et[i], NULL, exceptionedThread, NULL) == 0);
}
- Sleep(NUMTHREADS * 100);
-
- assert(caught == NUMTHREADS);
+ Sleep(NUMTHREADS * 10);
/*
- * Success.
+ * Fail. Should never be reached.
*/
- return 0;
+ return 1;
}
#else /* defined(__cplusplus) */