//my_pxsem_svsem/sem_getvalue.c
#include	"unpipc.h"
#include	"semaphore.h"

int
mysem_getvalue(mysem_t *sem, int *pvalue)
{
	int		val;

	if (sem->sem_magic != SEM_MAGIC) {
		errno = EINVAL;
		return(-1);
	}

	if ( (val = semctl(sem->sem_semid, 0, GETVAL)) < 0)
		return(-1);
	*pvalue = val;
	return(0);
}
