On 10/07/16 13:35, Christophe Milard wrote:
Implemented by calling the related functions from _ishm.

Signed-off-by: Christophe Milard <[email protected]>
---
  platform/linux-generic/odp_shared_memory.c | 38 ++++++++++++++++++++++++++----
  1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/platform/linux-generic/odp_shared_memory.c 
b/platform/linux-generic/odp_shared_memory.c
index 30ef9d9..5439116 100644
--- a/platform/linux-generic/odp_shared_memory.c
+++ b/platform/linux-generic/odp_shared_memory.c
@@ -24,6 +24,23 @@ 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)
+{
+       int flgs = 0; /* internal ishm flags */
+
clang must warn that you return signed in unsigned function.
Also name is not friendly for reading. Name it just 'f' or 'ret'.

+       /* 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 */
+       flgs |= (flags & ODP_SHM_PROC) ? _ODP_ISHM_LINK : 0;
+       flgs |= (flags & ODP_SHM_EXPORT) ? _ODP_ISHM_LINK : 0;
f |= (flags & (ODP_SHM_PROC | ODP_SHM_EXPORT) ? _ODP_ISHM_LINK : 0);

+       flgs |= (flags & ODP_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0;
+       flgs |= (flags & ODP_SHM_LOCK) ? _ODP_ISHM_LOCK : 0;
+

Can duplication of flags be avoided? I.e. go with just ODP_SHM_ ?

+       return flgs;
+}
+
  int odp_shm_capability(odp_shm_capability_t *capa)
  {
        memset(capa, 0, sizeof(odp_shm_capability_t));
@@ -41,10 +58,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 +67,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 flgs = 0; /* internal ishm flags */
no need to set to 0. flgs and flags hard to differ.
+
+       flgs = get_ishm_flags(flags);
+
+       ret =  _odp_ishm_reserve_exported(remote_name, (pid_t)odp_inst,
+                                         local_name, align, flgs, flags);
+
+       return to_handle(ret);
+}
+
  int odp_shm_free(odp_shm_t shm)
  {
        return _odp_ishm_free_by_index(from_handle(shm));

Reply via email to