diff mbox

[9/9] linux-generic: shm: add strong typing support

Message ID 1422592065-15875-10-git-send-email-bill.fischofer@linaro.org
State New
Headers show

Commit Message

Bill Fischofer Jan. 30, 2015, 4:27 a.m. UTC
Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/include/odp/plat/shared_memory_types.h | 7 +++++--
 platform/linux-generic/odp_shared_memory.c                    | 4 ++--
 2 files changed, 7 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..409eb8d 100644
--- a/platform/linux-generic/include/odp/plat/shared_memory_types.h
+++ b/platform/linux-generic/include/odp/plat/shared_memory_types.h
@@ -18,14 +18,17 @@ 
 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
 
 /**
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);
 }