|
Packit |
857059 |
/* BEGIN_ICS_COPYRIGHT3 ****************************************
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Copyright (c) 2015, Intel Corporation
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Redistribution and use in source and binary forms, with or without
|
|
Packit |
857059 |
modification, are permitted provided that the following conditions are met:
|
|
Packit |
857059 |
|
|
Packit |
857059 |
* Redistributions of source code must retain the above copyright notice,
|
|
Packit |
857059 |
this list of conditions and the following disclaimer.
|
|
Packit |
857059 |
* Redistributions in binary form must reproduce the above copyright
|
|
Packit |
857059 |
notice, this list of conditions and the following disclaimer in the
|
|
Packit |
857059 |
documentation and/or other materials provided with the distribution.
|
|
Packit |
857059 |
* Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
857059 |
may be used to endorse or promote products derived from this software
|
|
Packit |
857059 |
without specific prior written permission.
|
|
Packit |
857059 |
|
|
Packit |
857059 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
857059 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
857059 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
857059 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
Packit |
857059 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
857059 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
857059 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Packit |
857059 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Packit |
857059 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
857059 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
857059 |
|
|
Packit |
857059 |
** END_ICS_COPYRIGHT3 ****************************************/
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/* [ICS VERSION STRING: unknown] */
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifndef _IBA_PUBLIC_ISEMAPHORE_OSD_H_
|
|
Packit |
857059 |
#define _IBA_PUBLIC_ISEMAPHORE_OSD_H_
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#include "iba/public/datatypes.h"
|
|
Packit |
857059 |
#include <semaphore.h>
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifdef __cplusplus
|
|
Packit |
857059 |
extern "C" {
|
|
Packit |
857059 |
#endif
|
|
Packit |
857059 |
|
|
Packit |
857059 |
typedef sem_t SEMAPHORE;
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* SemaInitState
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Description:
|
|
Packit |
857059 |
* Initializes the state of a semaphore.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Inputs:
|
|
Packit |
857059 |
* pSema - Pointer to a semaphore object.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Outputs:
|
|
Packit |
857059 |
* None
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Returns:
|
|
Packit |
857059 |
* None
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
static __inline void
|
|
Packit |
857059 |
SemaInitState(
|
|
Packit |
857059 |
IN SEMAPHORE* const pSema )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
/* No-op. */
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* SemaInit
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Description:
|
|
Packit |
857059 |
* Initializes the semaphore. This function performs all initialization.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Inputs:
|
|
Packit |
857059 |
* pSema - Pointer to a semaphore object
|
|
Packit |
857059 |
* MaxCount - Maximum number of wait operations that the semaphore can
|
|
Packit |
857059 |
* satisfy before blocking callers.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Outputs:
|
|
Packit |
857059 |
* None
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Returns:
|
|
Packit |
857059 |
* FSUCCESS
|
|
Packit |
857059 |
* FERROR - Initialization failed.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
static __inline FSTATUS
|
|
Packit |
857059 |
SemaInit(
|
|
Packit |
857059 |
IN SEMAPHORE* const pSema,
|
|
Packit |
857059 |
IN const int32 MaxCount )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pSema );
|
|
Packit |
857059 |
ASSERT( MaxCount );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if (-1 == sem_init( pSema, 0, MaxCount ))
|
|
Packit |
857059 |
return FERROR;
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
return FSUCCESS;
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* SemaDestroy
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Description:
|
|
Packit |
857059 |
* Destroys the semaphore.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Inputs:
|
|
Packit |
857059 |
* pSema - Pointer to a semaphore object
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Outputs:
|
|
Packit |
857059 |
* None
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Returns:
|
|
Packit |
857059 |
* None
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
static __inline void
|
|
Packit |
857059 |
SemaDestroy(
|
|
Packit |
857059 |
IN SEMAPHORE* const pSema )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
ASSERT( pSema );
|
|
Packit |
857059 |
sem_destroy(pSema);
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* SemaAcquire
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Description:
|
|
Packit |
857059 |
* Acquires a semaphore. This call blocks for the specified interval if the
|
|
Packit |
857059 |
* semaphore cannot be acquired immediately. A wait of SEMA_NO_TIMEOUT
|
|
Packit |
857059 |
* will never timeout.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Inputs:
|
|
Packit |
857059 |
* pSema - Pointer to a semaphore object
|
|
Packit |
857059 |
* wait_us - Time, in microseconds, to wait for the semaphore.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Outputs:
|
|
Packit |
857059 |
* None
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Returns:
|
|
Packit |
857059 |
* FSUCCESS - The samphore was successfully acquired.
|
|
Packit |
857059 |
* FTIMEOUT - The operation timed out.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
FSTATUS
|
|
Packit |
857059 |
SemaAcquire(
|
|
Packit |
857059 |
IN SEMAPHORE* const pSema,
|
|
Packit |
857059 |
IN const int32 wait_us );
|
|
Packit |
857059 |
|
|
Packit |
857059 |
/****************************************************************************
|
|
Packit |
857059 |
* SemaRelease
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Description:
|
|
Packit |
857059 |
* Releases a semaphore. This will free one blocking waiter, if any.
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Inputs:
|
|
Packit |
857059 |
* pSema - Pointer to a semaphore object
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Outputs:
|
|
Packit |
857059 |
* None
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
* Returns:
|
|
Packit |
857059 |
* None
|
|
Packit |
857059 |
*
|
|
Packit |
857059 |
****************************************************************************/
|
|
Packit |
857059 |
static __inline void
|
|
Packit |
857059 |
SemaRelease(
|
|
Packit |
857059 |
IN SEMAPHORE* const pSema )
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
sem_post(pSema);
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#ifdef __cplusplus
|
|
Packit |
857059 |
} /* extern "C" */
|
|
Packit |
857059 |
#endif
|
|
Packit |
857059 |
|
|
Packit |
857059 |
#endif /* _IBA_PUBLIC_ISEMAPHORE_OSD_H_ */
|