eal: simplify meson build of common directory
[dpdk.git] / lib / librte_eal / common / include / rte_bitmap.h
index d9facc6..6b846f2 100644 (file)
@@ -43,10 +43,6 @@ extern "C" {
 #include <rte_branch_prediction.h>
 #include <rte_prefetch.h>
 
-#ifndef RTE_BITMAP_OPTIMIZATIONS
-#define RTE_BITMAP_OPTIMIZATIONS                        1
-#endif
-
 /* Slab */
 #define RTE_BITMAP_SLAB_BIT_SIZE                 64
 #define RTE_BITMAP_SLAB_BIT_SIZE_LOG2            6
@@ -88,7 +84,7 @@ __rte_bitmap_index1_inc(struct rte_bitmap *bmp)
 static inline uint64_t
 __rte_bitmap_mask1_get(struct rte_bitmap *bmp)
 {
-       return (~1lu) << bmp->offset1;
+       return (~1llu) << bmp->offset1;
 }
 
 static inline void
@@ -97,43 +93,6 @@ __rte_bitmap_index2_set(struct rte_bitmap *bmp)
        bmp->index2 = (((bmp->index1 << RTE_BITMAP_SLAB_BIT_SIZE_LOG2) + bmp->offset1) << RTE_BITMAP_CL_SLAB_SIZE_LOG2);
 }
 
-#if RTE_BITMAP_OPTIMIZATIONS
-
-static inline int
-rte_bsf64(uint64_t slab, uint32_t *pos)
-{
-       if (likely(slab == 0)) {
-               return 0;
-       }
-
-       *pos = __builtin_ctzll(slab);
-       return 1;
-}
-
-#else
-
-static inline int
-rte_bsf64(uint64_t slab, uint32_t *pos)
-{
-       uint64_t mask;
-       uint32_t i;
-
-       if (likely(slab == 0)) {
-               return 0;
-       }
-
-       for (i = 0, mask = 1; i < RTE_BITMAP_SLAB_BIT_SIZE; i ++, mask <<= 1) {
-               if (unlikely(slab & mask)) {
-                       *pos = i;
-                       return 1;
-               }
-       }
-
-       return 0;
-}
-
-#endif
-
 static inline uint32_t
 __rte_bitmap_get_memory_footprint(uint32_t n_bits,
        uint32_t *array1_byte_offset, uint32_t *array1_slabs,
@@ -317,7 +276,7 @@ rte_bitmap_get(struct rte_bitmap *bmp, uint32_t pos)
        index2 = pos >> RTE_BITMAP_SLAB_BIT_SIZE_LOG2;
        offset2 = pos & RTE_BITMAP_SLAB_BIT_MASK;
        slab2 = bmp->array2 + index2;
-       return (*slab2) & (1lu << offset2);
+       return (*slab2) & (1llu << offset2);
 }
 
 /**
@@ -342,8 +301,8 @@ rte_bitmap_set(struct rte_bitmap *bmp, uint32_t pos)
        slab2 = bmp->array2 + index2;
        slab1 = bmp->array1 + index1;
 
-       *slab2 |= 1lu << offset2;
-       *slab1 |= 1lu << offset1;
+       *slab2 |= 1llu << offset2;
+       *slab1 |= 1llu << offset1;
 }
 
 /**
@@ -370,7 +329,7 @@ rte_bitmap_set_slab(struct rte_bitmap *bmp, uint32_t pos, uint64_t slab)
        slab1 = bmp->array1 + index1;
 
        *slab2 |= slab;
-       *slab1 |= 1lu << offset1;
+       *slab1 |= 1llu << offset1;
 }
 
 static inline uint64_t
@@ -408,7 +367,7 @@ rte_bitmap_clear(struct rte_bitmap *bmp, uint32_t pos)
        slab2 = bmp->array2 + index2;
 
        /* Return if array2 slab is not all-zeros */
-       *slab2 &= ~(1lu << offset2);
+       *slab2 &= ~(1llu << offset2);
        if (*slab2){
                return;
        }
@@ -424,7 +383,7 @@ rte_bitmap_clear(struct rte_bitmap *bmp, uint32_t pos)
        index1 = pos >> (RTE_BITMAP_SLAB_BIT_SIZE_LOG2 + RTE_BITMAP_CL_BIT_SIZE_LOG2);
        offset1 = (pos >> RTE_BITMAP_CL_BIT_SIZE_LOG2) & RTE_BITMAP_SLAB_BIT_MASK;
        slab1 = bmp->array1 + index1;
-       *slab1 &= ~(1lu << offset1);
+       *slab1 &= ~(1llu << offset1);
 
        return;
 }
@@ -439,9 +398,8 @@ __rte_bitmap_scan_search(struct rte_bitmap *bmp)
        value1 = bmp->array1[bmp->index1];
        value1 &= __rte_bitmap_mask1_get(bmp);
 
-       if (rte_bsf64(value1, &bmp->offset1)) {
+       if (rte_bsf64_safe(value1, &bmp->offset1))
                return 1;
-       }
 
        __rte_bitmap_index1_inc(bmp);
        bmp->offset1 = 0;
@@ -450,9 +408,8 @@ __rte_bitmap_scan_search(struct rte_bitmap *bmp)
        for (i = 0; i < bmp->array1_size; i ++, __rte_bitmap_index1_inc(bmp)) {
                value1 = bmp->array1[bmp->index1];
 
-               if (rte_bsf64(value1, &bmp->offset1)) {
+               if (rte_bsf64_safe(value1, &bmp->offset1))
                        return 1;
-               }
        }
 
        return 0;