@@ -206,90 +206,3 @@ void PyThread_release_lock(PyThread_type_lock lock)
206206 status = pth_cond_notify ( & thelock -> lock_released , 0 );
207207 CHECK_STATUS ("pth_cond_notify" );
208208}
209-
210- /*
211- * Semaphore support.
212- */
213-
214- struct semaphore {
215- pth_mutex_t mutex ;
216- pth_cond_t cond ;
217- int value ;
218- };
219-
220- PyThread_type_sema PyThread_allocate_sema (int value )
221- {
222- struct semaphore * sema ;
223- int status , error = 0 ;
224-
225- dprintf (("PyThread_allocate_sema called\n" ));
226- if (!initialized )
227- PyThread_init_thread ();
228-
229- sema = (struct semaphore * ) malloc (sizeof (struct semaphore ));
230- if (sema != NULL ) {
231- sema -> value = value ;
232- status = pth_mutex_init (& sema -> mutex );
233- CHECK_STATUS ("pth_mutex_init" );
234- status = pth_cond_init (& sema -> cond );
235- CHECK_STATUS ("pth_mutex_init" );
236- if (error ) {
237- free ((void * ) sema );
238- sema = NULL ;
239- }
240- }
241- dprintf (("PyThread_allocate_sema() -> %p\n" , sema ));
242- return (PyThread_type_sema ) sema ;
243- }
244-
245- void PyThread_free_sema (PyThread_type_sema sema )
246- {
247- struct semaphore * thesema = (struct semaphore * ) sema ;
248-
249- dprintf (("PyThread_free_sema(%p) called\n" , sema ));
250- free ((void * ) thesema );
251- }
252-
253- int PyThread_down_sema (PyThread_type_sema sema , int waitflag )
254- {
255- int status , error = 0 , success ;
256- struct semaphore * thesema = (struct semaphore * ) sema ;
257-
258- dprintf (("PyThread_down_sema(%p, %d) called\n" , sema , waitflag ));
259- status = pth_mutex_acquire (& thesema -> mutex , !waitflag , NULL );
260- CHECK_STATUS ("pth_mutex_acquire" );
261- if (waitflag ) {
262- while (!error && thesema -> value <= 0 ) {
263- status = pth_cond_await (& thesema -> cond ,
264- & thesema -> mutex , NULL );
265- CHECK_STATUS ("pth_cond_await" );
266- }
267- }
268- if (error )
269- success = 0 ;
270- else if (thesema -> value > 0 ) {
271- thesema -> value -- ;
272- success = 1 ;
273- }
274- else
275- success = 0 ;
276- status = pth_mutex_release (& thesema -> mutex );
277- CHECK_STATUS ("pth_mutex_release" );
278- dprintf (("PyThread_down_sema(%p) return\n" , sema ));
279- return success ;
280- }
281-
282- void PyThread_up_sema (PyThread_type_sema sema )
283- {
284- int status , error = 0 ;
285- struct semaphore * thesema = (struct semaphore * ) sema ;
286-
287- dprintf (("PyThread_up_sema(%p)\n" , sema ));
288- status = pth_mutex_acquire (& thesema -> mutex , 0 , NULL );
289- CHECK_STATUS ("pth_mutex_acquire" );
290- thesema -> value ++ ;
291- status = pth_cond_notify (& thesema -> cond , 1 );
292- CHECK_STATUS ("pth_cond_notify" );
293- status = pth_mutex_release (& thesema -> mutex );
294- CHECK_STATUS ("pth_mutex_release" );
295- }
0 commit comments