net: fix build with gcc 4.4.7 and strict aliasing
[dpdk.git] / lib / librte_net / rte_ip.h
index 71c519a..5b7554a 100644 (file)
@@ -169,7 +169,8 @@ __rte_raw_cksum(const void *buf, size_t len, uint32_t sum)
 {
        /* workaround gcc strict-aliasing warning */
        uintptr_t ptr = (uintptr_t)buf;
-       const uint16_t *u16 = (const uint16_t *)ptr;
+       typedef uint16_t __attribute__((__may_alias__)) u16_p;
+       const u16_p *u16 = (const u16_p *)ptr;
 
        while (len >= (sizeof(*u16) * 4)) {
                sum += u16[0];