[Python-checkins] CVS: python/dist/src/Python thread_beos.h,2.8,2.9 thread_cthread.h,2.16,2.17 thread_foobar.h,2.12,2.13 thread_lwp.h,2.15,2.16 thread_nt.h,2.20,2.21 thread_os2.h,2.12,2.13 thread_pth.h,2.8,2.9 thread_pthread.h,2.37,2.38 thread_sgi.h,2.15,2.16 thread_solaris.h,2.17,2.18

Fred L. Drake fdrake@users.sourceforge.net
Sat, 19 Jan 2002 14:02:58 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv20723/Python

Modified Files:
	thread_beos.h thread_cthread.h thread_foobar.h thread_lwp.h 
	thread_nt.h thread_os2.h thread_pth.h thread_pthread.h 
	thread_sgi.h thread_solaris.h 
Log Message:
Remove the unused & broken PyThread_*_sema() functions and related constants.
This closes SF patch #504215.


Index: thread_beos.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_beos.h,v
retrieving revision 2.8
retrieving revision 2.9
diff -C2 -d -r2.8 -r2.9
*** thread_beos.h	2001/11/28 22:07:30	2.8
--- thread_beos.h	2002/01/19 22:02:55	2.9
***************
*** 286,357 ****
  	}
  }
- 
- /* ----------------------------------------------------------------------
-  * Semaphore support.
-  *
-  * Guido says not to implement this because it's not used anywhere;
-  * I'll do it anyway, you never know when it might be handy, and it's
-  * easy...
-  */
- PyThread_type_sema PyThread_allocate_sema( int value )
- {
- 	sem_id sema;
- 	
- 	dprintf(("PyThread_allocate_sema called\n"));
- 
- 	sema = create_sem( value, "python semaphore" );
- 	if( sema < B_NO_ERROR ) {
- 		/* TODO: that's bad, raise an exception */
- 		return 0;
- 	}
- 
- 	dprintf(("PyThread_allocate_sema() -> %p\n", sema));
- 	return (PyThread_type_sema) sema;
- }
- 
- void PyThread_free_sema( PyThread_type_sema sema )
- {
- 	status_t retval;
- 	
- 	dprintf(("PyThread_free_sema(%p) called\n", sema));
- 	
- 	retval = delete_sem( (sem_id)sema );
- 	if( retval != B_NO_ERROR ) {
- 		/* TODO: that's bad, raise an exception */
- 		return;
- 	}
- }
- 
- int PyThread_down_sema( PyThread_type_sema sema, int waitflag )
- {
- 	status_t retval;
- 
- 	dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
- 
- 	if( waitflag ) {
- 		retval = acquire_sem( (sem_id)sema );
- 	} else {
- 		retval = acquire_sem_etc( (sem_id)sema, 1, B_TIMEOUT, 0 );
- 	}
- 	
- 	if( retval != B_NO_ERROR ) {
- 		/* TODO: that's bad, raise an exception */
- 		return 0;
- 	}
- 
- 	dprintf(("PyThread_down_sema(%p) return\n", sema));
- 	return -1;
- }
- 
- void PyThread_up_sema( PyThread_type_sema sema )
- {
- 	status_t retval;
- 	
- 	dprintf(("PyThread_up_sema(%p)\n", sema));
- 	
- 	retval = release_sem( (sem_id)sema );
- 	if( retval != B_NO_ERROR ) {
- 		/* TODO: that's bad, raise an exception */
- 		return;
- 	}
- }
--- 286,287 ----

Index: thread_cthread.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_cthread.h,v
retrieving revision 2.16
retrieving revision 2.17
diff -C2 -d -r2.16 -r2.17
*** thread_cthread.h	2002/01/01 18:41:33	2.16
--- thread_cthread.h	2002/01/19 22:02:55	2.17
***************
*** 155,202 ****
  	mutex_unlock((mutex_t )lock);
  }
- 
- /*
-  * Semaphore support.
-  *
-  * This implementation is ripped directly from the pthreads implementation.
-  * Which is to say that it is 100% non-functional at this time.
-  *
-  * Assuming the page is still up, documentation can be found at:
-  *
-  * http://www.doc.ic.ac.uk/~mac/manuals/solaris-manual-pages/solaris/usr/man/man2/_lwp_sema_wait.2.html
-  *
-  * Looking at the man page, it seems that one could easily implement a
-  * semaphore using a condition.
-  *
-  */
- PyThread_type_sema
- PyThread_allocate_sema(int value)
- {
- 	char *sema = 0;
- 	dprintf(("PyThread_allocate_sema called\n"));
- 	if (!initialized)
- 		PyThread_init_thread();
- 
- 	dprintf(("PyThread_allocate_sema() -> %p\n", sema));
- 	return (PyThread_type_sema) sema;
- }
- 
- void
- PyThread_free_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_free_sema(%p) called\n", sema));
- }
- 
- int
- PyThread_down_sema(PyThread_type_sema sema, int waitflag)
- {
- 	dprintf(("PyThread_down_sema(%p, %d) called\n", sema, waitflag));
- 	dprintf(("PyThread_down_sema(%p) return\n", sema));
- 	return -1;
- }
- 
- void
- PyThread_up_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_up_sema(%p)\n", sema));
- }
--- 155,156 ----

Index: thread_foobar.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_foobar.h,v
retrieving revision 2.12
retrieving revision 2.13
diff -C2 -d -r2.12 -r2.13
*** thread_foobar.h	2001/10/16 21:13:49	2.12
--- thread_foobar.h	2002/01/19 22:02:55	2.13
***************
*** 114,149 ****
  	dprintf(("PyThread_release_lock(%p) called\n", lock));
  }
- 
- /*
-  * Semaphore support.
-  */
- PyThread_type_sema
- PyThread_allocate_sema(int value)
- {
- 	dprintf(("PyThread_allocate_sema called\n"));
- 	if (!initialized)
- 		PyThread_init_thread();
- 
- 	dprintf(("PyThread_allocate_sema() -> %p\n",  sema));
- 	return (PyThread_type_sema) sema;
- }
- 
- void
- PyThread_free_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_free_sema(%p) called\n",  sema));
- }
- 
- int
- PyThread_down_sema(PyThread_type_sema sema, int waitflag)
- {
- 	dprintf(("PyThread_down_sema(%p, %d) called\n",  sema, waitflag));
- 	dprintf(("PyThread_down_sema(%p) return\n",  sema));
- 	return -1;
- }
- 
- void
- PyThread_up_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_up_sema(%p)\n",  sema));
- }
--- 114,115 ----

Index: thread_lwp.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_lwp.h,v
retrieving revision 2.15
retrieving revision 2.16
diff -C2 -d -r2.15 -r2.16
*** thread_lwp.h	2001/10/16 21:13:49	2.15
--- thread_lwp.h	2002/01/19 22:02:55	2.16
***************
*** 148,180 ****
  	mon_exit(((struct lock *) lock)->lock_monitor);
  }
- 
- /*
-  * Semaphore support.
-  */
- PyThread_type_sema PyThread_allocate_sema(int value)
- {
- 	PyThread_type_sema sema = 0;
- 	dprintf(("PyThread_allocate_sema called\n"));
- 	if (!initialized)
- 		PyThread_init_thread();
- 
- 	dprintf(("PyThread_allocate_sema() -> %p\n",  sema));
- 	return (PyThread_type_sema) sema;
- }
- 
- void PyThread_free_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_free_sema(%p) called\n",  sema));
- }
- 
- int PyThread_down_sema(PyThread_type_sema sema, int waitflag)
- {
- 	dprintf(("PyThread_down_sema(%p, %d) called\n",  sema, waitflag));
- 	dprintf(("PyThread_down_sema(%p) return\n",  sema));
- 	return -1;
- }
- 
- void PyThread_up_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_up_sema(%p)\n",  sema));
- }
--- 148,149 ----

Index: thread_nt.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v
retrieving revision 2.20
retrieving revision 2.21
diff -C2 -d -r2.20 -r2.21
*** thread_nt.h	2001/10/16 21:50:04	2.20
--- thread_nt.h	2002/01/19 22:02:55	2.21
***************
*** 320,374 ****
  		dprintf(("%ld: Could not PyThread_release_lock(%p) error: %l\n", PyThread_get_thread_ident(), aLock, GetLastError()));
  }
- 
- /*
-  * Semaphore support.
-  */
- PyThread_type_sema PyThread_allocate_sema(int value)
- {
- 	HANDLE aSemaphore;
- 
- 	dprintf(("%ld: PyThread_allocate_sema called\n", PyThread_get_thread_ident()));
- 	if (!initialized)
- 		PyThread_init_thread();
- 
- 	aSemaphore = CreateSemaphore( NULL,           /* Security attributes          */
- 	                              value,          /* Initial value                */
- 	                              INT_MAX,        /* Maximum value                */
- 	                              NULL);          /* Name of semaphore            */
- 
- 	dprintf(("%ld: PyThread_allocate_sema() -> %p\n", PyThread_get_thread_ident(), aSemaphore));
- 
- 	return (PyThread_type_sema) aSemaphore;
- }
- 
- void PyThread_free_sema(PyThread_type_sema aSemaphore)
- {
- 	dprintf(("%ld: PyThread_free_sema(%p) called\n", PyThread_get_thread_ident(), aSemaphore));
- 
- 	CloseHandle((HANDLE) aSemaphore);
- }
- 
- /*
-   XXX must do something about waitflag
-  */
- int PyThread_down_sema(PyThread_type_sema aSemaphore, int waitflag)
- {
- 	DWORD waitResult;
- 
- 	dprintf(("%ld: PyThread_down_sema(%p) called\n", PyThread_get_thread_ident(), aSemaphore));
- 
- 	waitResult = WaitForSingleObject( (HANDLE) aSemaphore, INFINITE);
- 
- 	dprintf(("%ld: PyThread_down_sema(%p) return: %l\n", PyThread_get_thread_ident(), aSemaphore, waitResult));
- 	return 0;
- }
- 
- void PyThread_up_sema(PyThread_type_sema aSemaphore)
- {
- 	ReleaseSemaphore(
-                 (HANDLE) aSemaphore,            /* Handle of semaphore                          */
-                 1,                              /* increment count by one                       */
-                 NULL);                          /* not interested in previous count             */
-                                                 
- 	dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore));
- }
--- 320,321 ----

Index: thread_os2.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_os2.h,v
retrieving revision 2.12
retrieving revision 2.13
diff -C2 -d -r2.12 -r2.13
*** thread_os2.h	2001/10/31 03:50:45	2.12
--- thread_os2.h	2002/01/19 22:02:55	2.13
***************
*** 210,238 ****
    DosExitCritSec();
  }
- 
- /*
-  * Semaphore support.
-  */
- PyThread_type_sema 
- PyThread_allocate_sema(int value)
- {
-   return (PyThread_type_sema) 0;
- }
- 
- void 
- PyThread_free_sema(PyThread_type_sema aSemaphore)
- {
- 
- }
- 
- int 
- PyThread_down_sema(PyThread_type_sema aSemaphore, int waitflag)
- {
-   return -1;
- }
- 
- void 
- PyThread_up_sema(PyThread_type_sema aSemaphore)
- {
-   dprintf(("%ld: PyThread_up_sema(%p)\n", PyThread_get_thread_ident(), aSemaphore));
- }
--- 210,211 ----

Index: thread_pth.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_pth.h,v
retrieving revision 2.8
retrieving revision 2.9
diff -C2 -d -r2.8 -r2.9
*** thread_pth.h	2001/10/16 21:13:49	2.8
--- thread_pth.h	2002/01/19 22:02:55	2.9
***************
*** 207,295 ****
          CHECK_STATUS("pth_cond_notify");
  }
- 
- /*
-  * Semaphore support.
-  */
- 
- struct semaphore {
- 	pth_mutex_t mutex;
- 	pth_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 = pth_mutex_init(&sema->mutex);
- 		CHECK_STATUS("pth_mutex_init");
- 		status = pth_cond_init(&sema->cond);
- 		CHECK_STATUS("pth_mutex_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)
- {
- 	struct semaphore *thesema = (struct semaphore *) sema;
- 
- 	dprintf(("PyThread_free_sema(%p) called\n",  sema));
- 	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 = pth_mutex_acquire(&thesema->mutex, !waitflag, NULL);
- 	CHECK_STATUS("pth_mutex_acquire");
- 	if (waitflag) {
- 		while (!error && thesema->value <= 0) {
- 			status = pth_cond_await(&thesema->cond,
- 						&thesema->mutex, NULL);
- 			CHECK_STATUS("pth_cond_await");
- 		}
- 	}
- 	if (error)
- 		success = 0;
- 	else if (thesema->value > 0) {
- 		thesema->value--;
- 		success = 1;
- 	}
- 	else
- 		success = 0;
- 	status = pth_mutex_release(&thesema->mutex);
- 	CHECK_STATUS("pth_mutex_release");
- 	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 = pth_mutex_acquire(&thesema->mutex, 0, NULL);
- 	CHECK_STATUS("pth_mutex_acquire");
- 	thesema->value++;
- 	status = pth_cond_notify(&thesema->cond, 1);
- 	CHECK_STATUS("pth_cond_notify");
- 	status = pth_mutex_release(&thesema->mutex);
- 	CHECK_STATUS("pth_mutex_release");
- }
--- 207,208 ----

Index: thread_pthread.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v
retrieving revision 2.37
retrieving revision 2.38
diff -C2 -d -r2.37 -r2.38
*** thread_pthread.h	2002/01/15 20:36:14	2.37
--- thread_pthread.h	2002/01/19 22:02:55	2.38
***************
*** 406,505 ****
  	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");
- }
--- 406,407 ----

Index: thread_sgi.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_sgi.h,v
retrieving revision 2.15
retrieving revision 2.16
diff -C2 -d -r2.15 -r2.16
*** thread_sgi.h	2001/10/16 21:13:49	2.15
--- thread_sgi.h	2002/01/19 22:02:55	2.16
***************
*** 380,427 ****
  
  /*
-  * Semaphore support.
-  */
- PyThread_type_sema PyThread_allocate_sema(int value)
- {
- 	usema_t *sema;
- 	dprintf(("PyThread_allocate_sema called\n"));
- 	if (!initialized)
- 		PyThread_init_thread();
- 
- 	if ((sema = usnewsema(shared_arena, value)) == NULL)
- 		perror("usnewsema");
- 	dprintf(("PyThread_allocate_sema() -> %p\n",  sema));
- 	return (PyThread_type_sema) sema;
- }
- 
- void PyThread_free_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_free_sema(%p) called\n",  sema));
- 	usfreesema((usema_t *) sema, shared_arena);
- }
- 
- int PyThread_down_sema(PyThread_type_sema sema, int waitflag)
- {
- 	int success;
- 
- 	dprintf(("PyThread_down_sema(%p) called\n",  sema));
- 	if (waitflag)
- 		success = uspsema((usema_t *) sema);
- 	else
- 		success = uscpsema((usema_t *) sema);
- 	if (success < 0)
- 		perror(waitflag ? "uspsema" : "uscpsema");
- 	dprintf(("PyThread_down_sema(%p) return\n",  sema));
- 	return success;
- }
- 
- void PyThread_up_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_up_sema(%p)\n",  sema));
- 	if (usvsema((usema_t *) sema) < 0)
- 		perror("usvsema");
- }
- 
- /*
   * Per-thread data ("key") support.
   */
--- 380,383 ----

Index: thread_solaris.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_solaris.h,v
retrieving revision 2.17
retrieving revision 2.18
diff -C2 -d -r2.17 -r2.18
*** thread_solaris.h	2002/01/12 11:05:12	2.17
--- thread_solaris.h	2002/01/19 22:02:55	2.18
***************
*** 175,236 ****
  		perror("mutex_unlock");
  }
- 
- /*
-  * Semaphore support.
-  */
- PyThread_type_sema 
- PyThread_allocate_sema(int value)
- {
- 	sema_t *sema;
- 	dprintf(("PyThread_allocate_sema called\n"));
- 	if (!initialized)
- 		PyThread_init_thread();
- 
- 	sema = (sema_t *) malloc(sizeof(sema_t));
- 	if (sema_init(sema, value, USYNC_THREAD, 0)) {
- 		perror("sema_init");
- 		free((void *) sema);
- 		sema = 0;
- 	}
- 	dprintf(("PyThread_allocate_sema() -> %p\n",  sema));
- 	return (PyThread_type_sema) sema;
- }
- 
- void 
- PyThread_free_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_free_sema(%p) called\n",  sema));
- 	if (sema_destroy((sema_t *) sema))
- 		perror("sema_destroy");
- 	free((void *) sema);
- }
- 
- int 
- PyThread_down_sema(PyThread_type_sema sema, int waitflag)
- {
- 	int success;
- 
- 	dprintf(("PyThread_down_sema(%p) called\n",  sema));
- 	if (waitflag)
- 		success = sema_wait((sema_t *) sema);
- 	else
- 		success = sema_trywait((sema_t *) sema);
- 	if (success < 0) {
- 		if (errno == EBUSY)
- 			success = 0;
- 		else
- 			perror("sema_wait");
- 	}
- 	else
- 		success = !success;
- 	dprintf(("PyThread_down_sema(%p) return %d\n",  sema, success));
- 	return success;
- }
- 
- void 
- PyThread_up_sema(PyThread_type_sema sema)
- {
- 	dprintf(("PyThread_up_sema(%p)\n",  sema));
- 	if (sema_post((sema_t *) sema))
- 		perror("sema_post");
- }
--- 175,176 ----