diff options
author | marha <marha@users.sourceforge.net> | 2013-02-13 10:41:10 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-02-13 10:41:10 +0100 |
commit | b41f74438672dd682bc01ae818cb3da654f22c1e (patch) | |
tree | 07674ef1368a5427a75080528d8cee74234f6b28 /pthreads/tests/exception3.c | |
parent | aaf21968deb85b635cb6aa6544df233ea5981346 (diff) | |
download | vcxsrv-b41f74438672dd682bc01ae818cb3da654f22c1e.tar.gz vcxsrv-b41f74438672dd682bc01ae818cb3da654f22c1e.tar.bz2 vcxsrv-b41f74438672dd682bc01ae818cb3da654f22c1e.zip |
Updated to latest CVS version of pthreads
Diffstat (limited to 'pthreads/tests/exception3.c')
-rw-r--r-- | pthreads/tests/exception3.c | 41 |
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) */ |