Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Oct 10, 2024
1 parent b469480 commit 043f465
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 56 deletions.
39 changes: 20 additions & 19 deletions src/os/inc/osapi-binsem.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,27 +179,32 @@ int32 OS_BinSemDelete(osal_id_t sem_id);
int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name);

#ifdef OSAL_OMIT_DEPRECATED
#else
/*-------------------------------------------------------------------------------------*/
/**
* @brief Get the name of the binary semaphore
* @brief Fill a property object buffer with details regarding the resource
*
* This function retrieves the name of the specified binary semaphore.
* This function will pass back a pointer to structure that contains
* all of the relevant info( name and creator) about the specified binary
* semaphore.
*
* @param[in] sem_id The object ID to operate on
* @param[out] bin_prop The property object buffer to fill @nonnull
* @param[out] bin_prop The property object buffer to fill @nonnull
*
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore
* @retval #OS_INVALID_POINTER if the bin_prop pointer is null
* @retval #OS_ERR_NOT_IMPLEMENTED @copybrief OS_ERR_NOT_IMPLEMENTED
*/
int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);
int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);
#endif

/*-------------------------------------------------------------------------------------*/
/**
* @brief Get the creator of the binary semaphore
* @brief Get the name of the binary semaphore
*
* This function retrieves the creator of the specified binary semaphore.
* This function retrieves the name of the specified binary semaphore.
*
* @param[in] sem_id The object ID to operate on
* @param[out] bin_prop The property object buffer to fill @nonnull
Expand All @@ -209,13 +214,13 @@ int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);
* @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore
* @retval #OS_INVALID_POINTER if the bin_prop pointer is null
*/
int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);
int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Get the value of the binary semaphore
* @brief Get the creator of the binary semaphore
*
* This function retrieves the value of the specified binary semaphore.
* This function retrieves the creator of the specified binary semaphore.
*
* @param[in] sem_id The object ID to operate on
* @param[out] bin_prop The property object buffer to fill @nonnull
Expand All @@ -224,29 +229,25 @@ int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore
* @retval #OS_INVALID_POINTER if the bin_prop pointer is null
* @retval #OS_ERR_NOT_IMPLEMENTED @copybrief OS_ERR_NOT_IMPLEMENTED
*/
int32 OS_BinSemGetValue(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);
#else
int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);

/*-------------------------------------------------------------------------------------*/
/**
* @brief Fill a property object buffer with details regarding the resource
* @brief Get the value of the binary semaphore
*
* This function will pass back a pointer to structure that contains
* all of the relevant info( name and creator) about the specified binary
* semaphore.
* This function retrieves the value of the specified binary semaphore.
*
* @param[in] sem_id The object ID to operate on
* @param[out] bin_prop The property object buffer to fill @nonnull
* @param[out] bin_prop The property object buffer to fill @nonnull
*
* @return Execution status, see @ref OSReturnCodes
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
* @retval #OS_ERR_INVALID_ID if the id passed in is not a valid semaphore
* @retval #OS_INVALID_POINTER if the bin_prop pointer is null
* @retval #OS_ERR_NOT_IMPLEMENTED @copybrief OS_ERR_NOT_IMPLEMENTED
*/
int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);
#endif
int32 OS_BinSemGetValue(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop);

/**@}*/

Expand Down
22 changes: 19 additions & 3 deletions src/os/posix/src/os-impl-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,17 +466,33 @@ int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs)
return (OS_GenericBinSemTake_Impl(token, &ts));
}

#ifdef OSAL_OMIT_DEPRECATED
#else
/*----------------------------------------------------------------
*
* Purpose: Implemented per internal OSAL API
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
#ifdef OSAL_OMIT_DEPRECATED
int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *sem_prop)
#else
int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *sem_prop)
{
OS_impl_binsem_internal_record_t *sem;

sem = OS_OBJECT_TABLE_GET(OS_impl_bin_sem_table, *token);

/* put the info into the structure */
sem_prop->value = sem->current_value;
return OS_SUCCESS;
}
#endif

/*----------------------------------------------------------------
*
* Purpose: Implemented per internal OSAL API
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *sem_prop)
{
OS_impl_binsem_internal_record_t *sem;

Expand Down
17 changes: 14 additions & 3 deletions src/os/rtems/src/os-impl-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,28 @@ int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs)
return OS_SUCCESS;
}

#ifdef OSAL_OMIT_DEPRECATED
#else
/*----------------------------------------------------------------
*
* Purpose: Implemented per internal OSAL API
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
#ifdef OSAL_OMIT_DEPRECATED
int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop)
#else
int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop)
{
/* RTEMS has no API for obtaining the current value of a semaphore */
return OS_ERR_NOT_IMPLEMENTED;
}
#endif

/*----------------------------------------------------------------
*
* Purpose: Implemented per internal OSAL API
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop)
{
/* RTEMS has no API for obtaining the current value of a semaphore */
return OS_ERR_NOT_IMPLEMENTED;
Expand Down
16 changes: 12 additions & 4 deletions src/os/shared/inc/os-shared-binsem.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,24 @@ int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs);
------------------------------------------------------------------*/
int32 OS_BinSemDelete_Impl(const OS_object_token_t *token);


#ifdef OSAL_OMIT_DEPRECATED
#else
/*----------------------------------------------------------------
Purpose: Obtain the value of a semaphore (if possible/implemented in the relevent OS)
Purpose: Obtain OS-specific information about the semaphore
Returns: OS_SUCCESS on success, or relevant error code
------------------------------------------------------------------*/
#ifdef OSAL_OMIT_DEPRECATED
int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop);
#else
int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop);
#endif

/*----------------------------------------------------------------
Purpose: Obtain the value of a semaphore (if possible/implemented in the relevent OS)
Returns: OS_SUCCESS on success, or relevant error code
------------------------------------------------------------------*/
int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop);

#endif /* OS_SHARED_BINSEM_H */
55 changes: 31 additions & 24 deletions src/os/shared/src/osapi-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,46 +243,45 @@ int32 OS_BinSemGetIdByName(osal_id_t *sem_id, const char *sem_name)
return return_code;
}

#ifdef OSAL_OMIT_DEPRECATED
#else
/*----------------------------------------------------------------
*
* Purpose: Implemented per public OSAL API
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
#ifdef OSAL_OMIT_DEPRECATED
int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
{
OS_common_record_t *record;
OS_object_token_t token;
int32 return_code;

/* Check parameters */
OS_CHECK_POINTER(bin_prop);

memset(bin_prop, 0, sizeof(OS_bin_sem_prop_t));

/* Check Parameters */
return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &token);
if (return_code == OS_SUCCESS)
{
record = OS_OBJECT_TABLE_GET(OS_global_bin_sem_table, token);

strncpy(bin_prop->name, record->name_entry, sizeof(bin_prop->name) - 1);
bin_prop->name[sizeof(bin_prop->name) - 1] = '\0'; /* Ensure null termination */
bin_prop->creator = record->creator;
return_code = OS_BinSemGetInfo_Impl(&token, bin_prop);

OS_ObjectIdRelease(&token);
}

return return_code;
}
#endif

/*----------------------------------------------------------------
*
* Purpose: Implemented per public OSAL API
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
int32 OS_BinSemGetName(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
{
OS_common_record_t *record;
OS_object_token_t token;
Expand All @@ -299,7 +298,8 @@ int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
{
record = OS_OBJECT_TABLE_GET(OS_global_bin_sem_table, token);

bin_prop->creator = record->creator;
strncpy(bin_prop->name, record->name_entry, sizeof(bin_prop->name) - 1);
bin_prop->name[sizeof(bin_prop->name) - 1] = '\0'; /* Ensure null termination */

OS_ObjectIdRelease(&token);
}
Expand All @@ -313,10 +313,11 @@ int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetValue(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
int32 OS_BinSemGetCreator(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
{
OS_object_token_t token;
int32 return_code;
OS_common_record_t *record;
OS_object_token_t token;
int32 return_code;

/* Check parameters */
OS_CHECK_POINTER(bin_prop);
Expand All @@ -327,34 +328,40 @@ int32 OS_BinSemGetValue(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &token);
if (return_code == OS_SUCCESS)
{
return_code = OS_BinSemGetValue_Impl(&token, bin_prop);
record = OS_OBJECT_TABLE_GET(OS_global_bin_sem_table, token);

bin_prop->creator = record->creator;

OS_ObjectIdRelease(&token);
}

return return_code;
}
#else
int32 OS_BinSemGetInfo(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)

/*----------------------------------------------------------------
*
* Purpose: Implemented per public OSAL API
* See description in API and header file for detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetValue(osal_id_t sem_id, OS_bin_sem_prop_t *bin_prop)
{
OS_common_record_t *record;
OS_object_token_t token;
int32 return_code;
OS_object_token_t token;
int32 return_code;

/* Check parameters */
OS_CHECK_POINTER(bin_prop);

memset(bin_prop, 0, sizeof(OS_bin_sem_prop_t));

/* Check Parameters */
return_code = OS_ObjectIdGetById(OS_LOCK_MODE_GLOBAL, LOCAL_OBJID_TYPE, sem_id, &token);
if (return_code == OS_SUCCESS)
{
record = OS_OBJECT_TABLE_GET(OS_global_bin_sem_table, token);

strncpy(bin_prop->name, record->name_entry, sizeof(bin_prop->name) - 1);
bin_prop->creator = record->creator;
return_code = OS_BinSemGetInfo_Impl(&token, bin_prop);
return_code = OS_BinSemGetValue_Impl(&token, bin_prop);

OS_ObjectIdRelease(&token);
}

return return_code;
}
#endif
17 changes: 14 additions & 3 deletions src/os/vxworks/src/os-impl-binsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,28 @@ int32 OS_BinSemTimedWait_Impl(const OS_object_token_t *token, uint32 msecs)
return status;
}

#ifdef OSAL_OMIT_DEPRECATED
#else
/*----------------------------------------------------------------
*
* Purpose: Implemented per internal OSAL API
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
#ifdef OSAL_OMIT_DEPRECATED
int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop)
#else
int32 OS_BinSemGetInfo_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop)
{
/* VxWorks has no API for obtaining the current value of a semaphore */
return OS_ERR_NOT_IMPLEMENTED;
}
#endif

/*----------------------------------------------------------------
*
* Purpose: Implemented per internal OSAL API
* See prototype for argument/return detail
*
*-----------------------------------------------------------------*/
int32 OS_BinSemGetValue_Impl(const OS_object_token_t *token, OS_bin_sem_prop_t *bin_prop)
{
/* VxWorks has no API for obtaining the current value of a semaphore */
return OS_ERR_NOT_IMPLEMENTED;
Expand Down

0 comments on commit 043f465

Please # to comment.