diff mbox

[PATCHv5,19/19] linux-generic: shm: add strong typing support

Message ID 1422938699-12877-20-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit ee9c7da43269236f989fc3add46f5544bff2c3e7
Headers show

Commit Message

Bill Fischofer Feb. 3, 2015, 4:44 a.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 .../linux-generic/include/odp/plat/shared_memory_types.h    | 13 +++++++++++--
 platform/linux-generic/odp_shared_memory.c                  |  4 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp/plat/shared_memory_types.h b/platform/linux-generic/include/odp/plat/shared_memory_types.h
index c044cb9..d2e92cf 100644
--- a/platform/linux-generic/include/odp/plat/shared_memory_types.h
+++ b/platform/linux-generic/include/odp/plat/shared_memory_types.h
@@ -18,16 +18,25 @@ 
 extern "C" {
 #endif
 
+#include <odp/std_types.h>
+#include <odp/plat/strong_types.h>
+
 /** @addtogroup odp_shared_memory ODP SHARED MEMORY
  *  Operations on shared memory.
  *  @{
  */
 
-typedef uint32_t odp_shm_t;
+typedef odp_handle_t odp_shm_t;
 
-#define ODP_SHM_INVALID 0
+#define ODP_SHM_INVALID _odp_cast_scalar(odp_shm_t, 0)
 #define ODP_SHM_NULL ODP_SHM_INVALID
 
+/** Get printable format of odp_shm_t */
+static inline uint64_t odp_shm_to_u64(odp_shm_t hdl)
+{
+	return _odp_pri(hdl);
+}
+
 /**
  * @}
  */
diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index 96d10e8..dbaec22 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -64,13 +64,13 @@  static odp_shm_table_t *odp_shm_tbl;
 
 static inline uint32_t from_handle(odp_shm_t shm)
 {
-	return shm - 1;
+	return _odp_typeval(shm) - 1;
 }
 
 
 static inline odp_shm_t to_handle(uint32_t index)
 {
-	return index + 1;
+	return _odp_cast_scalar(odp_shm_t, index + 1);
 }