Skip to content

Commit

Permalink
Add workaround for plist struct alignment for Zephyr
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Masselink <patrick.masselink@zettascale.tech>
  • Loading branch information
PatrickM-ZS committed Feb 21, 2023
1 parent da9f87b commit 4927618
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/core/ddsi/src/ddsi_plist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2361,15 +2361,15 @@ static void plist_or_xqos_fini (void * __restrict dst, size_t shift, uint64_t pm
break;
assert (entry->plist_offset >= shift);
assert (shift == 0 || entry->plist_offset - shift < sizeof (dds_qos_t));
size_t dstoff = entry->plist_offset - shift;
size_t dstoff = 0;
struct flagset * const fs = (entry->flags & PDF_QOS) ? &qfs : &pfs;
uint64_t mask = (entry->flags & PDF_QOS) ? qmask : pmask;
if (*fs->present & entry->present_flag & mask)
{
if (!(entry->flags & PDF_FUNCTION))
fini_generic (dst, &dstoff, fs, entry->present_flag, entry->op.desc);
fini_generic ((char*)dst+entry->plist_offset-shift, &dstoff, fs, entry->present_flag, entry->op.desc);
else if (entry->op.f.fini)
entry->op.f.fini (dst, &dstoff, fs, entry->present_flag);
entry->op.f.fini ((char*)dst+entry->plist_offset-shift, &dstoff, fs, entry->present_flag);
}
}
}
Expand Down Expand Up @@ -2402,14 +2402,14 @@ static void plist_or_xqos_unalias (void * __restrict dst, size_t shift)
break;
assert (entry->plist_offset >= shift);
assert (shift == 0 || entry->plist_offset - shift < sizeof (dds_qos_t));
size_t dstoff = entry->plist_offset - shift;
size_t dstoff = 0;
struct flagset * const fs = (entry->flags & PDF_QOS) ? &qfs : &pfs;
if ((*fs->present & entry->present_flag) && (*fs->aliased & entry->present_flag))
{
if (!(entry->flags & PDF_FUNCTION))
unalias_generic (dst, &dstoff, false, entry->op.desc);
unalias_generic ((char*)dst+entry->plist_offset-shift, &dstoff, false, entry->op.desc);
else if (entry->op.f.unalias)
entry->op.f.unalias (dst, &dstoff, false);
entry->op.f.unalias ((char*)dst+entry->plist_offset-shift, &dstoff, false);
*fs->aliased &= ~entry->present_flag;
}
}
Expand Down Expand Up @@ -2457,7 +2457,7 @@ static void plist_or_xqos_mergein_missing (void * __restrict dst, const void * _
break;
assert (entry->plist_offset >= shift);
assert (shift == 0 || entry->plist_offset - shift < sizeof (dds_qos_t));
size_t dstoff = entry->plist_offset - shift;
size_t dstoff = 0;
struct flagset * const fs_dst = (entry->flags & PDF_QOS) ? &qfs_dst : &pfs_dst;
struct flagset * const fs_src = (entry->flags & PDF_QOS) ? &qfs_src : &pfs_src;
uint64_t const mask = (entry->flags & PDF_QOS) ? qmask : pmask;
Expand All @@ -2470,12 +2470,12 @@ static void plist_or_xqos_mergein_missing (void * __restrict dst, const void * _
Note: dst & src have the same type, so offset in src is the same;
Note: unalias may have to look at */
memcpy ((char *) dst + dstoff, (const char *) src + dstoff, entry->size);
memcpy ((char*)dst+entry->plist_offset-shift, (const char *)src+entry->plist_offset-shift, entry->size);
*fs_dst->present |= entry->present_flag;
if (!(entry->flags & PDF_FUNCTION))
unalias_generic (dst, &dstoff, true, entry->op.desc);
unalias_generic ((char*)dst+entry->plist_offset-shift, &dstoff, true, entry->op.desc);
else if (entry->op.f.unalias)
entry->op.f.unalias (dst, &dstoff, true);
entry->op.f.unalias ((char*)dst+entry->plist_offset-shift, &dstoff, true);
}
}
}
Expand Down Expand Up @@ -2515,11 +2515,11 @@ static void plist_or_xqos_addtomsg (struct ddsi_xmsg *xmsg, const void * __restr
{
assert (entry->plist_offset >= shift);
assert (shift == 0 || entry->plist_offset - shift < sizeof (dds_qos_t));
size_t srcoff = entry->plist_offset - shift;
size_t srcoff = 0;
if (!(entry->flags & PDF_FUNCTION))
ser_generic (xmsg, entry->pid, src, srcoff, entry->op.desc, bo);
ser_generic (xmsg, entry->pid, (char*)src+entry->plist_offset-shift, srcoff, entry->op.desc, bo);
else
entry->op.f.ser (xmsg, entry->pid, src, srcoff, bo, context_kind);
entry->op.f.ser (xmsg, entry->pid, (char*)src+entry->plist_offset-shift, srcoff, bo, context_kind);
}
}
}
Expand Down Expand Up @@ -2564,11 +2564,11 @@ static dds_return_t ddsi_xqos_valid_strictness (const struct ddsrt_log_cfg *logc
break;
if (xqos->present & entry->present_flag)
{
const size_t srcoff = entry->plist_offset - offsetof (ddsi_plist_t, qos);
const size_t srcoff = 0;
if (!(entry->flags & PDF_FUNCTION))
ret = valid_generic (xqos, srcoff, entry->op.desc);
ret = valid_generic ((char*)xqos+entry->plist_offset - offsetof (ddsi_plist_t, qos), srcoff, entry->op.desc);
else
ret = entry->op.f.valid (xqos, srcoff);
ret = entry->op.f.valid ((char*)xqos+entry->plist_offset - offsetof (ddsi_plist_t, qos), srcoff);
if (ret < 0)
{
DDS_CLOG (DDS_LC_PLIST, logcfg, "ddsi_xqos_valid: %s invalid\n", entry->name);
Expand Down Expand Up @@ -2627,17 +2627,16 @@ static void plist_or_xqos_delta (uint64_t *pdelta, uint64_t *qdelta, const void
uint64_t * const delta = (entry->flags & PDF_QOS) ? qdelta : pdelta;
if (check & entry->present_flag)
{
const size_t off = entry->plist_offset - shift;
bool equal;
/* Partition is special-cased because it is a set (with a special rules
for empty sets and empty strings to boot), and normal string sequence
comparison requires the ordering to be the same */
if (entry->pid == DDSI_PID_PARTITION)
equal = partitions_equal (srcx, srcy, off);
equal = partitions_equal (srcx+entry->plist_offset - shift, srcy+entry->plist_offset - shift, 0);
else if (!(entry->flags & PDF_FUNCTION))
equal = equal_generic (srcx, srcy, off, entry->op.desc);
equal = equal_generic (srcx+entry->plist_offset - shift, srcy+entry->plist_offset - shift, 0, entry->op.desc);
else
equal = entry->op.f.equal (srcx, srcy, off);
equal = entry->op.f.equal (srcx+entry->plist_offset - shift, srcy+entry->plist_offset - shift, 0);
if (!equal)
*delta |= entry->present_flag;
}
Expand Down

0 comments on commit 4927618

Please sign in to comment.