diff mbox

[PATCHv5,2/2] linux-generic: extend odp_shm_reserve flags in platform code

Message ID 1409844928-30604-3-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Sept. 4, 2014, 3:35 p.m. UTC
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 .../linux-generic/include/api/odp_shared_memory.h  |  2 --
 .../include/odp_shared_memory_internal.h           | 35 ++++++++++++++++++++++
 platform/linux-generic/odp_buffer_pool.c           |  1 +
 platform/linux-generic/odp_queue.c                 |  3 +-
 platform/linux-generic/odp_shared_memory.c         |  9 +++++-
 5 files changed, 46 insertions(+), 4 deletions(-)
 create mode 100644 platform/linux-generic/include/odp_shared_memory_internal.h
diff mbox

Patch

diff --git a/platform/linux-generic/include/api/odp_shared_memory.h b/platform/linux-generic/include/api/odp_shared_memory.h
index 1d8e8bb..f12aeea 100644
--- a/platform/linux-generic/include/api/odp_shared_memory.h
+++ b/platform/linux-generic/include/api/odp_shared_memory.h
@@ -28,8 +28,6 @@  typedef enum {
 	ODP_SHM_THREAD = 1,        /**< Memory accessible by threads.  */
 	ODP_SHM_PROC = 2,          /**< Memory accessible by processes.
 				    Will be created if not exist.  */
-	ODP_SHM_PROC_NOCREAT = 3,  /**< Memory accessible by processes.
-				    Has to be created before usage.*/
 } odp_shm_e;
 
 /**
diff --git a/platform/linux-generic/include/odp_shared_memory_internal.h b/platform/linux-generic/include/odp_shared_memory_internal.h
new file mode 100644
index 0000000..856cf07
--- /dev/null
+++ b/platform/linux-generic/include/odp_shared_memory_internal.h
@@ -0,0 +1,35 @@ 
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP shared memory internal
+ */
+
+#ifndef ODP_SHARED_MEMORY_INTERNAL_H_
+#define ODP_SHARED_MEMORY_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_shared_memory.h>
+
+/*Extend odp_shm_e:
+ * ODP_SHM_PROC_NOCREAT - Memory accessible by processes has to be created
+ *			 before real usage.
+ */
+#define ODP_SHM_PROC_NOCREAT (ODP_SHM_PROC + 1)
+void *plat_odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
+		       odp_shm_e flag);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-generic/odp_buffer_pool.c b/platform/linux-generic/odp_buffer_pool.c
index 390e3a6..9103cfa 100644
--- a/platform/linux-generic/odp_buffer_pool.c
+++ b/platform/linux-generic/odp_buffer_pool.c
@@ -11,6 +11,7 @@ 
 #include <odp_packet_internal.h>
 #include <odp_timer_internal.h>
 #include <odp_shared_memory.h>
+#include <odp_shared_memory_internal.h>
 #include <odp_align.h>
 #include <odp_internal.h>
 #include <odp_config.h>
diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index 38796af..fc38b57 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -13,6 +13,7 @@ 
 #include <odp_buffer_pool_internal.h>
 #include <odp_internal.h>
 #include <odp_shared_memory.h>
+#include <odp_shared_memory_internal.h>
 #include <odp_schedule_internal.h>
 #include <odp_config.h>
 #include <odp_packet_io_internal.h>
@@ -100,7 +101,7 @@  static void queue_init(queue_entry_t *queue, const char *name,
 		if (odp_shm_lookup_ipc(name) == 1) {
 			size_t ring_size =  QUEUE_IPC_ENTRIES * sizeof(void *)
 					+ sizeof(odph_ring_t);
-			queue->s.r = odp_shm_reserve(name, ring_size,
+			queue->s.r = plat_odp_shm_reserve(name, ring_size,
 					ODP_CACHE_LINE_SIZE,
 					ODP_SHM_PROC_NOCREAT);
 			if (queue->s.r == NULL)
diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c
index b0b0935..3d90f4c 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -11,6 +11,8 @@ 
 #include <odp_system_info.h>
 #include <odp_debug.h>
 
+#include <odp_shared_memory_internal.h>
+
 #include <sys/mman.h>
 #include <asm/mman.h>
 #include <fcntl.h>
@@ -98,7 +100,7 @@  static int find_block(const char *name)
 }
 
 
-void *odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
+void *plat_odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
 		      odp_shm_e flag)
 {
 	int i, ret, shm_open_flags;
@@ -203,6 +205,11 @@  void *odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
 	return addr;
 }
 
+void *odp_shm_reserve(const char *name, uint64_t size, uint64_t align,
+		      odp_shm_e flag)
+{
+	return plat_odp_shm_reserve(name, size, align, flag);
+}
 
 void *odp_shm_lookup(const char *name)
 {