56 "ENV_SHM_ALIGNMENT_ERROR");
59 shared_reserve(
const char *name,
size_t size)
65 odp_shm_capability_t shm_capa;
66 int ret = odp_shm_capability(&shm_capa);
71 if (shm_capa.flags & ODP_SHM_SINGLE_VA)
72 flags |= ODP_SHM_SINGLE_VA;
74 shm = odp_shm_reserve(name, offsetof(
env_shm_buf_t, data) + size,
75 ODP_CACHE_LINE_SIZE, flags);
77 if (unlikely(shm == ODP_SHM_INVALID))
80 env_shm_buf = odp_shm_addr(shm);
81 env_shm_buf->hdr.odp_shm = shm;
83 return (
void *)env_shm_buf->data;
87 env_shared_reserve(
const char *name,
size_t size)
89 if (unlikely(name == NULL || size == 0))
92 return shared_reserve(name, size);
96 env_shared_lookup(
const char *name)
101 if (unlikely(name == NULL))
104 shm = odp_shm_lookup(name);
105 if (unlikely(shm == ODP_SHM_INVALID))
108 env_shm_buf = odp_shm_addr(shm);
110 return (
void *)env_shm_buf->data;
114 env_shared_malloc(
size_t size)
116 if (unlikely(size == 0))
119 return shared_reserve(NULL, size);
123 env_shared_free(
void *buf)
135 shm = env_shm_buf->hdr.odp_shm;
136 ret = odp_shm_free(shm);
137 if (unlikely(ret != 0))