src/ssx/ssx/ssx_semaphore_core.c
/// Get information about a semaphore.
///
/// \param semaphore A pointer to the SsxSemaphore to query
///
/// \param count The value returned through this pointer is the current count
/// of the semaphore.  The caller can set this parameter to the null pointer
/// (0) if this information is not required.
///
/// \param pending The value returned through this pointer is the current
/// number of threads pending on the semaphore. The caller can set this
/// parameter to the null pointer (0) if this information is not required.
///
/// The information returned by this API can only be guaranteed consistent if
/// the API is called from an SSX_NONCRITICAL critical section. Since the
/// implementation of this API does not require a critical section, it is not
/// an error to call this API from a critical interrupt context.
///
/// Return values other than SSX_OK (0) are errors; see \ref ssx_errors
///
/// \retval 0 Successful completion
///
/// \retval -SSX_INVALID_SEMAPHORE_AT_INFO The \a semaphore is a null (0)
/// pointer.
Get information about a semaphore.
\param semaphore A pointer to the SsxSemaphore to query

\param count The value returned through this pointer is the current count
of the semaphore.  The caller can set this parameter to the null pointer
(0) if this information is not required.

\param pending The value returned through this pointer is the current
number of threads pending on the semaphore. The caller can set this
parameter to the null pointer (0) if this information is not required.

The information returned by this API can only be guaranteed consistent if
the API is called from an SSX_NONCRITICAL critical section. Since the
implementation of this API does not require a critical section, it is not
an error to call this API from a critical interrupt context.

Return values other than SSX_OK (0) are errors; see \ref ssx_errors

\retval 0 Successful completion

\retval -SSX_INVALID_SEMAPHORE_AT_INFO The \a semaphore is a null (0)
pointer.
Get information about a semaphore . \ param semaphore A pointer to the SsxSemaphore to query \ param count The value returned through this pointer is the current count of the semaphore . The caller can set this parameter to the null pointer ( 0 ) if this information is not required . \ param pending The value returned through this pointer is the current number of threads pending on the semaphore . The caller can set this parameter to the null pointer ( 0 ) if this information is not required . The information returned by this API can only be guaranteed consistent if the API is called from an SSX_NONCRITICAL critical section . Since the implementation of this API does not require a critical section it is not an error to call this API from a critical interrupt context . Return values other than SSX_OK ( 0 ) are errors ; see \ ref ssx_errors \ retval 0 Successful completion \ retval - SSX_INVALID_SEMAPHORE_AT_INFO The \ a semaphore is a null ( 0 ) pointer .
int
ssx_semaphore_info_get(SsxSemaphore*      semaphore,
                       SsxSemaphoreCount* count,
                       int*               pending)
{
    if (SSX_ERROR_CHECK_API)
    {
        SSX_ERROR_IF(semaphore == 0, SSX_INVALID_SEMAPHORE_AT_INFO);
    }
    if (count)
    {
        *count = semaphore->count;
    }
    if (pending)
    {
        *pending = __ssx_thread_queue_count(&(semaphore->pending_threads));
    }
    return SSX_OK;
}
int ssx_semaphore_info_get ( SsxSemaphore * semaphore , SsxSemaphoreCount * count , int * pending ) { if ( SSX_ERROR_CHECK_API ) { SSX_ERROR_IF ( semaphore == 0 , SSX_INVALID_SEMAPHORE_AT_INFO ) ; } if ( count ) { * count = semaphore -> count ; } if ( pending ) { * pending = __ssx_thread_queue_count ( & ( semaphore -> pending_threads ) ) ; } return SSX_OK ; }
Get information about a semaphore.
Get information about a semaphore .