Implemented by calling the related functions from _ishm.

Signed-off-by: Christophe Milard <christophe.mil...@linaro.org>
---
 platform/linux-generic/odp_shared_memory.c | 37 ++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/platform/linux-generic/odp_shared_memory.c 
b/platform/linux-generic/odp_shared_memory.c
index 30ef9d9..1603cdb 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -24,6 +24,22 @@ static inline odp_shm_t to_handle(uint32_t index)
        return _odp_cast_scalar(odp_shm_t, index + 1);
 }
 
+static uint32_t get_ishm_flags(uint32_t flags)
+{
+       uint32_t f = 0; /* internal ishm flags */
+
+       /* set internal ishm flags according to API flags:
+        * note that both ODP_SHM_PROC and ODP_SHM_EXPORT maps to
+        * _ODP_ISHM_LINK as in the linux-gen implementation there is
+        * no difference between exporting to another ODP instance or
+        * another linux process */
+       f |= (flags & (ODP_SHM_PROC | ODP_SHM_EXPORT)) ? _ODP_ISHM_LINK : 0;
+       f |= (flags & ODP_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0;
+       f |= (flags & ODP_SHM_LOCK) ? _ODP_ISHM_LOCK : 0;
+
+       return f;
+}
+
 int odp_shm_capability(odp_shm_capability_t *capa)
 {
        memset(capa, 0, sizeof(odp_shm_capability_t));
@@ -41,10 +57,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, 
uint64_t align,
        int block_index;
        int flgs = 0; /* internal ishm flags */
 
-       /* set internal ishm flags according to API flags: */
-       flgs |= (flags & ODP_SHM_PROC) ? _ODP_ISHM_LINK : 0;
-       flgs |= (flags & ODP_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0;
-       flgs |= (flags & ODP_SHM_LOCK) ? _ODP_ISHM_LOCK : 0;
+       flgs = get_ishm_flags(flags);
 
        block_index = _odp_ishm_reserve(name, size, -1, align, flgs, flags);
        if (block_index >= 0)
@@ -53,6 +66,22 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, 
uint64_t align,
                return ODP_SHM_INVALID;
 }
 
+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)
+{
+       int ret;
+       int i_flgs; /* internal ishm flags */
+
+       i_flgs = get_ishm_flags(flags);
+
+       ret =  _odp_ishm_reserve_exported(remote_name, (pid_t)odp_inst,
+                                         local_name, align, i_flgs, flags);
+
+       return to_handle(ret);
+}
+
 int odp_shm_free(odp_shm_t shm)
 {
        return _odp_ishm_free_by_index(from_handle(shm));
-- 
2.7.4

Reply via email to