FreeBSD/lib/libc/gen/sem_new.c
/*
 * POSIX:
 * The sem_post() interface is reentrant with respect to signals and may be
 * invoked from a signal-catching function. 
 * The implementation does not use lock, so it should be safe.
 */
The sem_post() interface is reentrant with respect to signals and may be
invoked from a signal-catching function.
The implementation does not use lock, so it should be safe.
The sem_post () interface is reentrant with respect to signals and may be invoked from a signal - catching function . The implementation does not use lock so it should be safe .
int
_sem_post(sem_t *sem)
{
	unsigned int count;
	if (sem_check_validity(sem) != 0)
		return (-1);
	do {
		count = sem->_kern._count;
		if (USEM_COUNT(count) + 1 > SEM_VALUE_MAX) {
			errno = EOVERFLOW;
			return (-1);
		}
	} while (!atomic_cmpset_rel_int(&sem->_kern._count, count, count + 1));
	if (count & USEM_HAS_WAITERS)
		usem_wake(&sem->_kern);
	return (0);
}
int _sem_post ( sem_t * sem ) { unsigned int count ; if ( sem_check_validity ( sem ) != 0 ) return ( -1 ) ; do { count = sem -> _kern . _count ; if ( USEM_COUNT ( count ) + 1 > SEM_VALUE_MAX ) { errno = EOVERFLOW ; return ( -1 ) ; } } while ( ! atomic_cmpset_rel_int ( & sem -> _kern . _count , count , count + 1 ) ) ; if ( count & USEM_HAS_WAITERS ) usem_wake ( & sem -> _kern ) ; return ( 0 ) ; }
POSIX:
 The sem_post() interface is reentrant with respect to signals and may be
 invoked from a signal-catching function.
POSIX : The sem_post () interface is reentrant with respect to signals and may be invoked from a signal - catching function .