Interface: Refine OS wrapper APIs
For the following OS wrapper APIs
os_wrapper_thread_new
os_wrapper_thread_get_id
os_wrapper_thread_get_priority
os_wrapper_semaphore_create
os_wrapper_mutex_create
They return the corresponding IDs or priorities on success and
OS_WRAPPER_ERROR on failure.
This makes the "OS_WRAPPER_ERROR" value invalid for thread IDs,
mutex IDs...etc on all OSes.
But it could be a valid value on some OSes.
This patch fixes this problem by
1. Changing mutex, semaphore and thread IDs to handles
2. For os_wrapper_thread_get_priority, putting outputs to
parameters and returning only success or error.
For the others, treating NULL return as error and others for
valid handles.
Change-Id: I19aa0415ce0ba4388fb96602fea8f10f702d8c45
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/interface/include/os_wrapper/semaphore.h b/interface/include/os_wrapper/semaphore.h
index 38b9a16..89b00a0 100644
--- a/interface/include/os_wrapper/semaphore.h
+++ b/interface/include/os_wrapper/semaphore.h
@@ -21,42 +21,41 @@
* \param[in] initial_count Starting count of the semaphore
* \param[in] name Name of the semaphore
*
- * \return Returns ID of the semaphore created, or \ref OS_WRAPPER_ERROR in case
- * of error
+ * \return Returns handle of the semaphore created, or NULL in case of error
*/
-uint32_t os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count,
- const char *name);
+void *os_wrapper_semaphore_create(uint32_t max_count, uint32_t initial_count,
+ const char *name);
/**
* \brief Acquires the semaphore
*
- * \param[in] semaphore_id Semaphore ID
- * \param[in] timeout Timeout value
+ * \param[in] hanlde Semaphore handle
+ * \param[in] timeout Timeout value
*
* \return \ref OS_WRAPPER_SUCCESS in case of successful acquision, or
* \ref OS_WRAPPER_ERROR in case of error
*/
-uint32_t os_wrapper_semaphore_acquire(uint32_t semaphore_id, uint32_t timeout);
+uint32_t os_wrapper_semaphore_acquire(void *handle, uint32_t timeout);
/**
* \brief Releases the semaphore
*
- * \param[in] semaphore_id Semaphore ID
+ * \param[in] hanlde Semaphore handle
*
* \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
* \ref OS_WRAPPER_ERROR in case of error
*/
-uint32_t os_wrapper_semaphore_release(uint32_t semaphore_id);
+uint32_t os_wrapper_semaphore_release(void *handle);
/**
* \brief Deletes the semaphore
*
- * \param[in] semaphore_id Semaphore ID
+ * \param[in] handle Semaphore handle
*
* \return \ref OS_WRAPPER_SUCCESS in case of successful release, or
* \ref OS_WRAPPER_ERROR in case of error
*/
-uint32_t os_wrapper_semaphore_delete(uint32_t semaphore_id);
+uint32_t os_wrapper_semaphore_delete(void *handle);
#ifdef __cplusplus
}