summaryrefslogtreecommitdiff
path: root/Python/thread_pthread.h
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-01-19 22:02:55 +0000
committerFred Drake <fdrake@acm.org>2002-01-19 22:02:55 +0000
commit5bb87d1ac91fcee7dbda69bf6b0d07206145e1f5 (patch)
treeff548568ac0ad3d0705791c78fd5a4c76931c7b3 /Python/thread_pthread.h
parent8639b47495a14befbd949f2a1578d692e61513cc (diff)
downloadcpython-5bb87d1ac91fcee7dbda69bf6b0d07206145e1f5.tar.gz
Remove the unused & broken PyThread_*_sema() functions and related constants.
This closes SF patch #504215.
Diffstat (limited to 'Python/thread_pthread.h')
-rw-r--r--Python/thread_pthread.h98
1 files changed, 0 insertions, 98 deletions
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index 771e22e913..6e921287e1 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -405,101 +405,3 @@ PyThread_release_lock(PyThread_type_lock lock)
status = pthread_cond_signal( &thelock->lock_released );
CHECK_STATUS("pthread_cond_signal");
}
-
-/*
- * Semaphore support.
- */
-
-struct semaphore {
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- int value;
-};
-
-PyThread_type_sema
-PyThread_allocate_sema(int value)
-{
- struct semaphore *sema;
- int status, error = 0;
-
- dprintf(("PyThread_allocate_sema called\n"));
- if (!initialized)
- PyThread_init_thread();
-
- sema = (struct semaphore *) malloc(sizeof(struct semaphore));
- if (sema != NULL) {
- sema->value = value;
- status = pthread_mutex_init(&sema->mutex,
- pthread_mutexattr_default);
- CHECK_STATUS("pthread_mutex_init");
- status = pthread_cond_init(&sema->cond,
- pthread_condattr_default);
- CHECK_STATUS("pthread_cond_init");
- if (error) {
- free((void *) sema);
- sema = NULL;
- }
- }
- dprintf(("PyThread_allocate_sema() -> %p\n", sema));
- return (PyThread_type_sema) sema;
-}
-
-void
-PyThread_free_sema(PyThread_type_sema sema)
-{
- int status, error = 0;
- struct semaphore *thesema = (struct semaphore *) sema;
-
- dprintf(("PyThread_free_sema(%p) called\n", sema));
- status = pthread_cond_destroy(&thesema->cond);
- CHECK_STATUS("pthread_cond_destroy");
- status = pthread_mutex_destroy(&thesema->mutex);
- CHECK_STATUS("pthread_mutex_destroy");
- free((void *) thesema);
-}
-
-int
-PyThread_down_sema(PyThread_type_sema sema, int waitflag)
-{
- int status, error = 0, success;
- struct semaphore *thesema = (struct semaphore *) sema;
-
- dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
- status = pthread_mutex_lock(&thesema->mutex);
- CHECK_STATUS("pthread_mutex_lock");
- if (waitflag) {
- while (!error && thesema->value <= 0) {
- status = pthread_cond_wait(&thesema->cond,
- &thesema->mutex);
- CHECK_STATUS("pthread_cond_wait");
- }
- }
- if (error)
- success = 0;
- else if (thesema->value > 0) {
- thesema->value--;
- success = 1;
- }
- else
- success = 0;
- status = pthread_mutex_unlock(&thesema->mutex);
- CHECK_STATUS("pthread_mutex_unlock");
- dprintf(("PyThread_down_sema(%p) return\n", sema));
- return success;
-}
-
-void
-PyThread_up_sema(PyThread_type_sema sema)
-{
- int status, error = 0;
- struct semaphore *thesema = (struct semaphore *) sema;
-
- dprintf(("PyThread_up_sema(%p)\n", sema));
- status = pthread_mutex_lock(&thesema->mutex);
- CHECK_STATUS("pthread_mutex_lock");
- thesema->value++;
- status = pthread_cond_signal(&thesema->cond);
- CHECK_STATUS("pthread_cond_signal");
- status = pthread_mutex_unlock(&thesema->mutex);
- CHECK_STATUS("pthread_mutex_unlock");
-}