summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--implement.h14
-rw-r--r--ptw32_MCS_lock.c9
-rw-r--r--ptw32_threadStart.c15
4 files changed, 19 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index be0a351..25efebe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
* several (MINGW64): Cast and call fixups for 64 bit compatibility;
clean build via x86_64-w64-mingw32 cross toolchain on Linux i686
targeting x86_64 win64.
+ * ptw32_threadStart.c (ptw32_threadStart): Routine no longer attempts
+ to pass [unexpected C++] exceptions out of scope but ends the thread
+ normally setting EINTR as the exit status.
2011-03-04 Ross Johnson <ross.johnson at homemail.com.au>
diff --git a/implement.h b/implement.h
index 5df0f93..807ae54 100644
--- a/implement.h
+++ b/implement.h
@@ -82,12 +82,16 @@ typedef VOID (APIENTRY *PAPCFUNC)(DWORD dwParam);
#define INLINE
#endif
-#if defined (__MINGW64__) || defined(__MINGW32__) || (_MSC_VER >= 1300)
-#define PTW32_INTERLOCKED_LONG long
-#define PTW32_INTERLOCKED_LPLONG long*
+#if defined (__MINGW64__) || defined(__MINGW32__) || defined(_MSC_VER)
+#define PTW32_INTERLOCKED_LONG unsigned long
+#define PTW32_INTERLOCKED_LPLONG volatile unsigned long*
+#define PTW32_INTERLOCKED_PVOID PVOID
+#define PTW32_INTERLOCKED_PVOID_PTR volatile PVOID*
#else
#define PTW32_INTERLOCKED_LONG PVOID
-#define PTW32_INTERLOCKED_LPLONG PVOID*
+#define PTW32_INTERLOCKED_LPLONG volatile PVOID*
+#define PTW32_INTERLOCKED_PVOID PVOID
+#define PTW32_INTERLOCKED_PVOID_PTR volatile PVOID*
#endif
#if defined(__MINGW64__) || defined(__MINGW32__)
@@ -594,7 +598,7 @@ extern "C"
void ptw32_rwlock_cancelwrwait (void *arg);
-#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || defined (__MSVCRT__)
+#if ! (defined (__MINGW64__) || defined(__MINGW32__)) || (defined (__MSVCRT__) && ! defined(__DMC__))
unsigned __stdcall
#else
void
diff --git a/ptw32_MCS_lock.c b/ptw32_MCS_lock.c
index ff74efa..08bea49 100644
--- a/ptw32_MCS_lock.c
+++ b/ptw32_MCS_lock.c
@@ -229,11 +229,10 @@ ptw32_mcs_lock_try_acquire (ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * no
node->readyFlag = 0;
node->next = 0; /* initially, no successor */
- return ((PTW32_INTERLOCKED_LPLONG)PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR(
- (PTW32_INTERLOCKED_LPLONG)lock,
- (PTW32_INTERLOCKED_LPLONG)node,
- (PTW32_INTERLOCKED_LPLONG)0)
- == (PTW32_INTERLOCKED_LPLONG)0) ? 0 : EBUSY;
+ return ((PVOID)PTW32_INTERLOCKED_COMPARE_EXCHANGE_PTR((LPVOID volatile *)lock,
+ (PVOID)node,
+ (PVOID)0)
+ == (PVOID)0) ? 0 : EBUSY;
}
/*
diff --git a/ptw32_threadStart.c b/ptw32_threadStart.c
index 8dcede3..3bc7ede 100644
--- a/ptw32_threadStart.c
+++ b/ptw32_threadStart.c
@@ -299,20 +299,11 @@ ptw32_threadStart (void *vthreadParms)
{
/*
* A system unexpected exception has occurred running the user's
- * terminate routine. We get control back within this block - cleanup
- * and release the exception out of thread scope.
+ * terminate routine. We get control back within this block
+ * and exit with a substitue status. If the thread was not
+ * cancelled then this indicates the unhandled exception.
*/
status = sp->exitStatus = PTHREAD_CANCELED;
- (void) pthread_mutex_lock (&sp->cancelLock);
- sp->state = PThreadStateException;
- (void) pthread_mutex_unlock (&sp->cancelLock);
- (void) pthread_win32_thread_detach_np ();
- (void) set_terminate (ptw32_oldTerminate);
- throw;
-
- /*
- * Never reached.
- */
}
(void) set_terminate (ptw32_oldTerminate);