diff mbox

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

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

Commit Message

Christophe Milard Oct. 24, 2016, 9:24 a.m. UTC
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 | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

-- 
2.7.4
diff mbox

Patch

diff --git a/include/odp/api/spec/shared_memory.h b/include/odp/api/spec/shared_memory.h
index cccc470..f071bba 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" {
@@ -62,6 +63,13 @@  extern "C" {
  * be swapped out (nor physically moved in physical address space).
  */
 #define ODP_SHM_LOCK		0x8
+/**
+ * Export memory
+ *
+ * When set, the memory block becomes visible to other ODP instances
+ * through odp_shm_reserve_exported().
+ */
+#define ODP_SHM_EXPORT		0x10
 
 /**
  * Shared memory block info
@@ -148,6 +156,24 @@  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 remote_name  Name of the block, in the remote ODP instance
+ * @param odp_inst     Remote ODP instance, as returned by odp_init_global()
+ * @param local_name   Name given to the block, in the local ODP instance
+ *		       (or NULL, if the application doesn't care)
+ * @param align        Block alignment in bytes
+ * @param 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