[2/2] mempool: use rte constant macro instead of GCC builtin
Checks
Commit Message
Use newly introduced __rte_constant(e) macro instead of directly using
__builtin_constant_p() allowing mempool to be built by MSVC.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/mempool/rte_mempool.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
Comments
> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Wednesday, 20 March 2024 22.34
>
> Use newly introduced __rte_constant(e) macro instead of directly using
> __builtin_constant_p() allowing mempool to be built by MSVC.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
Reviewed-by: Morten Brørup <mb@smartsharesystems.com>
@@ -1521,7 +1521,7 @@ struct rte_mempool_cache *
/* The cache is a stack, so copy will be in reverse order. */
cache_objs = &cache->objs[cache->len];
- if (__extension__(__builtin_constant_p(n)) && n <= cache->len) {
+ if (__rte_constant(n) && n <= cache->len) {
/*
* The request size is known at build time, and
* the entire request can be satisfied from the cache,
@@ -1542,8 +1542,7 @@ struct rte_mempool_cache *
* If the request size 'n' is known at build time, the above comparison
* ensures that n > cache->len here, so omit RTE_MIN().
*/
- len = __extension__(__builtin_constant_p(n)) ? cache->len :
- RTE_MIN(n, cache->len);
+ len = __rte_constant(n) ? cache->len : RTE_MIN(n, cache->len);
cache->len -= len;
remaining = n - len;
for (index = 0; index < len; index++)
@@ -1554,7 +1553,7 @@ struct rte_mempool_cache *
* where the entire request can be satisfied from the cache
* has already been handled above, so omit handling it here.
*/
- if (!__extension__(__builtin_constant_p(n)) && remaining == 0) {
+ if (!__rte_constant(n) && remaining == 0) {
/* The entire request is satisfied from the cache. */
RTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_bulk, 1);