Skip to content

Commit

Permalink
WIP: linux-gen: shm: refactor shm block naming
Browse files Browse the repository at this point in the history
  • Loading branch information
MatiasElo committed Jan 23, 2025
1 parent c82a1ec commit 75537ee
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions platform/linux-generic/odp_ishm.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,12 +934,10 @@ static int find_block_by_name(const char *name, odp_bool_t use_param_name)
*/
static void make_name_unique(char *block_name, const char *name, size_t sz)
{
int i = 0;

_odp_strcpy(block_name, name, sz);

while (find_block_by_name(block_name, false) >= 0)
_odp_snprint(block_name, sz, "%d-%s", i++, name);
if (name)
_odp_snprint(block_name, sz, "%08" PRIu64 "-%s", ishm_tbl->dev_seq++, name);
else
_odp_snprint(block_name, sz, "%08" PRIu64 "", ishm_tbl->dev_seq++);
}

/*
Expand Down Expand Up @@ -1113,13 +1111,14 @@ int _odp_ishm_reserve(const char *name, uint64_t size, int fd,

/* Save application given block name as-is and make internal block name used for mmap
unique */
make_name_unique(new_block->name, name, ISHM_NAME_MAXLEN);
if (name) {
make_name_unique(new_block->name, name, ISHM_NAME_MAXLEN);
_odp_strcpy(new_block->param_name, name, ISHM_NAME_MAXLEN);
} else {
new_block->name[0] = 0;
new_block->param_name[0] = 0;
name = new_block->name; /* Used for export file name */
}

new_block->offset = 0;

/* save user data: */
Expand Down

0 comments on commit 75537ee

Please sign in to comment.