[API-NEXT,PATCHv3,10/16] api: shmem: add flag and function to share memory between ODP instances

Message ID 1476890991-4693-11-git-send-email-christophe.milard@linaro.org
State New
Headers show

Commit Message

Christophe Milard Oct. 19, 2016, 3:29 p.m.
The flag ODP_SHM_EXPORT is added: when passed at odp_shm_reserve() time
the memory block becomes visible to other ODP instances.
The function odp_shm_reserve_exported() is added: this function enables to
reserve block of memories exported by other ODP instances (using the
ODP_SHM_EXPORT flag).

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 include/odp/api/spec/shared_memory.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

-- 
2.7.4

Patch

diff --git a/include/odp/api/spec/shared_memory.h b/include/odp/api/spec/shared_memory.h
index fe683d4..1b4d068 100644
--- a/include/odp/api/spec/shared_memory.h
+++ b/include/odp/api/spec/shared_memory.h
@@ -14,6 +14,7 @@ 
 #ifndef ODP_API_SHARED_MEMORY_H_
 #define ODP_API_SHARED_MEMORY_H_
 #include <odp/visibility_begin.h>
+#include <odp/api/init.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -49,6 +50,7 @@  extern "C" {
 #define ODP_SHM_PROC		0x2 /**< Share with external processes       */
 #define ODP_SHM_SINGLE_VA	0x4 /**< guarantee unique addr on all threads*/
 #define ODP_SHM_LOCK		0x8 /**< prevent swapping this memory        */
+#define ODP_SHM_EXPORT		0x10 /**< share with other ODP instances     */
 
 /**
  * Shared memory block info
@@ -135,6 +137,23 @@  int odp_shm_free(odp_shm_t shm);
  */
 odp_shm_t odp_shm_lookup(const char *name);
 
+/**
+ * get and reserve a block of shared memory, exported by another ODP instance
+ *
+ * @param[in] remote_name  Name of the block, in the remote ODP instance
+ * @param[in] odp_inst     Remote ODP instance, as returned by odp_init_global()
+ * @param[in] local_name   Name given to the block, in the local ODP instance
+ * @param[in] align        Block alignment in bytes
+ * @param[in] flags        Shared memory parameter flags (ODP_SHM_*).
+ *                         Default value is 0.
+ *
+ * @return A new handle to the block if it is found (must be freed when done).
+ * @retval ODP_SHM_INVALID on failure
+ */
+odp_shm_t odp_shm_reserve_exported(const char *remote_name,
+				   odp_instance_t odp_inst,
+				   const char *local_name,
+				   uint64_t align, uint32_t flags);
 
 /**
  * Shared memory block address