diff -ruN /usr/src/cygwin-1.3.10-1/winsup/cygwin/cygwin.din cygwin-1.3.10-1/winsup/cygwin/cygwin.din --- /usr/src/cygwin-1.3.10-1/winsup/cygwin/cygwin.din 2002-01-19 12:45:46.000000000 -0500 +++ cygwin-1.3.10-1/winsup/cygwin/cygwin.din 2002-06-28 15:30:48.000000000 -0400 @@ -1207,6 +1207,7 @@ sem_wait sem_trywait sem_post +sem_getvalue sched_get_priority_max sched_get_priority_min sched_getparam diff -ruN /usr/src/cygwin-1.3.10-1/winsup/cygwin/include/semaphore.h cygwin-1.3.10-1/winsup/cygwin/include/semaphore.h --- /usr/src/cygwin-1.3.10-1/winsup/cygwin/include/semaphore.h 2001-03-21 11:06:22.000000000 -0500 +++ cygwin-1.3.10-1/winsup/cygwin/include/semaphore.h 2002-06-28 15:30:48.000000000 -0400 @@ -33,6 +33,7 @@ int sem_wait (sem_t * sem); int sem_trywait (sem_t * sem); int sem_post (sem_t * sem); + int sem_getvalue(sem_t * sem, int * value); #ifdef __cplusplus } diff -ruN /usr/src/cygwin-1.3.10-1/winsup/cygwin/posix.sgml cygwin-1.3.10-1/winsup/cygwin/posix.sgml --- /usr/src/cygwin-1.3.10-1/winsup/cygwin/posix.sgml 2001-08-25 21:41:57.000000000 -0400 +++ cygwin-1.3.10-1/winsup/cygwin/posix.sgml 2002-06-28 15:30:48.000000000 -0400 @@ -52,7 +52,7 @@ Synchronization (Section 11) -sem_init, sem_destroy, sem_wait, sem_trywait, sem_post, +sem_init, sem_destroy, sem_wait, sem_trywait, sem_post, sem_getvalue pthread_mutex_init, pthread_mutex_destroy, pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_unlock diff -ruN /usr/src/cygwin-1.3.10-1/winsup/cygwin/pthread.cc cygwin-1.3.10-1/winsup/cygwin/pthread.cc --- /usr/src/cygwin-1.3.10-1/winsup/cygwin/pthread.cc 2001-10-05 01:05:09.000000000 -0400 +++ cygwin-1.3.10-1/winsup/cygwin/pthread.cc 2002-06-28 15:30:48.000000000 -0400 @@ -476,4 +476,10 @@ return __sem_post (sem); } +int +sem_getvalue (sem_t * sem, int * value) +{ + return __sem_post (sem); } + +} /* extern */ diff -ruN /usr/src/cygwin-1.3.10-1/winsup/cygwin/thread.cc cygwin-1.3.10-1/winsup/cygwin/thread.cc --- /usr/src/cygwin-1.3.10-1/winsup/cygwin/thread.cc 2002-01-08 00:16:29.000000000 -0500 +++ cygwin-1.3.10-1/winsup/cygwin/thread.cc 2002-06-28 15:30:48.000000000 -0400 @@ -793,6 +793,12 @@ } void +semaphore::GetValue (long * value) +{ + *value = currentvalue; +} + +void semaphore::Post () { /* we can't use the currentvalue, because the wait functions don't let us access it */ @@ -2238,4 +2244,14 @@ return 0; } +int +__sem_getvalue (sem_t *sem, long *value) +{ + if (verifyable_object_isvalid (sem, SEM_MAGIC) != VALID_OBJECT) + return EINVAL; + + (*sem)->GetValue (value); + return 0; +} + #endif // MT_SAFE diff -ruN /usr/src/cygwin-1.3.10-1/winsup/cygwin/thread.h cygwin-1.3.10-1/winsup/cygwin/thread.h --- /usr/src/cygwin-1.3.10-1/winsup/cygwin/thread.h 2002-02-19 22:25:01.000000000 -0500 +++ cygwin-1.3.10-1/winsup/cygwin/thread.h 2002-06-28 15:33:54.000000000 -0400 @@ -336,6 +336,7 @@ class semaphore * next; int shared; long currentvalue; + void GetValue (long * value); void Wait (); void Post (); int TryWait (); diff -ruN /usr/src/cygwin-1.3.10-1/winsup/doc/calls.texinfo cygwin-1.3.10-1/winsup/doc/calls.texinfo --- /usr/src/cygwin-1.3.10-1/winsup/doc/calls.texinfo 2000-07-21 19:28:23.000000000 -0400 +++ cygwin-1.3.10-1/winsup/doc/calls.texinfo 2002-06-28 15:30:48.000000000 -0400 @@ -422,7 +422,7 @@ @item pthread_mutex_unlock: P96 11.3.3.1 @item sem_close: P96 11.2.4.1 -- unimplemented @item sem_destroy: P96 11.2.2.1 -@item sem_getvalue: P96 11.2.8.1 -- unimplemented +@item sem_getvalue: P96 11.2.8.1 @item sem_init: P96 11.2.1.1 @item sem_open: P96 11.2.3.1 -- unimplemented @item sem_post: P96 11.2.7.1