eal: add macro to swap two variables
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>
This commit is contained in:
parent
6ded44bce4
commit
a0a388a897
@ -30,9 +30,13 @@ test_macros(int __rte_unused unused_parm)
|
||||
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)
|
||||
|
@ -778,6 +778,14 @@ rte_log2_u64(uint64_t v)
|
||||
})
|
||||
#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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user