Add a macro to swap two variables
and updat common autotest for the same.
Signed-off-by: Shijith Thotton <sthotton@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
return -1;}
uintptr_t unused = 0;
+ unsigned int smaller = SMALLER, bigger = BIGGER;
RTE_SET_USED(unused);
+ RTE_SWAP(smaller, bigger);
+ if (smaller != BIGGER && bigger != SMALLER)
+ FAIL_MACRO(RTE_SWAP);
if ((uintptr_t)RTE_PTR_ADD(SMALLER, PTR_DIFF) != BIGGER)
FAIL_MACRO(RTE_PTR_ADD);
if ((uintptr_t)RTE_PTR_SUB(BIGGER, PTR_DIFF) != SMALLER)
})
#endif
+/** Swap two variables. */
+#define RTE_SWAP(a, b) \
+ __extension__ ({ \
+ typeof (a) _a = a; \
+ a = b; \
+ b = _a; \
+ })
+
/**
* Get the size of a field in a structure.
*