summaryrefslogtreecommitdiffstats
path: root/Python/thread_pthread.h
diff options
context:
space:
mode:
Diffstat (limited to 'Python/thread_pthread.h')
-rw-r--r--Python/thread_pthread.h25
1 files changed, 11 insertions, 14 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index de42f1a..49713ce 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -148,7 +148,7 @@ typedef struct {
* Initialization.
*/
-#ifdef _HAVE_BSDI
+#if defined(_HAVE_BSDI)
static
void _noop(void)
{
@@ -244,8 +244,7 @@ PyThread_start_new_thread(void (*func)(void *), void *arg)
hosed" because:
- It does not guarantee the promise that a non-zero integer is returned.
- The cast to long is inherently unsafe.
- - It is not clear that the 'volatile' (for AIX?) and ugly casting in the
- latter return statement (for Alpha OSF/1) are any longer necessary.
+ - It is not clear that the 'volatile' (for AIX?) are any longer necessary.
*/
long
PyThread_get_thread_ident(void)
@@ -253,13 +252,8 @@ PyThread_get_thread_ident(void)
volatile pthread_t threadid;
if (!initialized)
PyThread_init_thread();
- /* Jump through some hoops for Alpha OSF/1 */
threadid = pthread_self();
-#if SIZEOF_PTHREAD_T <= SIZEOF_LONG
return (long) threadid;
-#else
- return (long) *(long *) &threadid;
-#endif
}
void
@@ -452,12 +446,15 @@ PyThread_free_lock(PyThread_type_lock lock)
dprintf(("PyThread_free_lock(%p) called\n", lock));
- status = pthread_mutex_destroy( &thelock->mut );
- CHECK_STATUS("pthread_mutex_destroy");
-
+ /* some pthread-like implementations tie the mutex to the cond
+ * and must have the cond destroyed first.
+ */
status = pthread_cond_destroy( &thelock->lock_released );
CHECK_STATUS("pthread_cond_destroy");
+ status = pthread_mutex_destroy( &thelock->mut );
+ CHECK_STATUS("pthread_mutex_destroy");
+
free((void *)thelock);
}
@@ -540,12 +537,12 @@ PyThread_release_lock(PyThread_type_lock lock)
thelock->locked = 0;
- status = pthread_mutex_unlock( &thelock->mut );
- CHECK_STATUS("pthread_mutex_unlock[3]");
-
/* wake up someone (anyone, if any) waiting on the lock */
status = pthread_cond_signal( &thelock->lock_released );
CHECK_STATUS("pthread_cond_signal");
+
+ status = pthread_mutex_unlock( &thelock->mut );
+ CHECK_STATUS("pthread_mutex_unlock[3]");
}
#endif /* USE_SEMAPHORES */