Thread (13 messages) 13 messages, 3 authors, 2015-06-24

Re: [PATCH v4 0/9] Improve cast alignment for strict aligned machines

From: Thomas Monjalon <hidden>
Date: 2015-06-24 10:05:12

2015-06-23 17:36, Olivier MATZ:
On 06/22/2015 08:34 PM, Cyril Chemparathy wrote:
quoted
This series contains a few improvements that allow the DPDK code base
to build properly on machines that enforce strict pointer cast
alignment constraints.

When dealing with packet data which could be arbitrarily aligned, we
get the compiler to do the right thing by (a) making sure that header
types are packed, and (b) introducing and using
unaligned_uint(16|32|64)_t types when upcasting from byte pointers.

In a few other instances, we know apriori that the pointer cast cannot
possibly break alignment.  This applies to the changes in mempool,
hash, mbuf, and the ethdev stats code.  Here, we simply silence the
compiler by casting through (void *) using the RTE_PTR_(ADD|SUB)
macros.

Finally, we introduce a new rte_pktmbuf_mtod_offset() helper to return
a type casted pointer to an offset within the packet data.  This
replaces the following commonly used pattern:
	(struct foo *)(rte_pktmbuf_mtod(m, char *) + offset)
with:
	rte_pktmbuf_mtod_offset(m, struct foo *, offset)

To ensure consistency, the above transform was applied throughout the
code base using the coccinelle semantic patching tool.
Series
Acked-by: Olivier Matz <redacted>
Applied, thanks
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help