eal: change power intrinsics API
[dpdk.git] / lib / librte_eal / common / malloc_elem.c
index 885d004..c2c9461 100644 (file)
@@ -18,6 +18,7 @@
 #include <rte_common.h>
 #include <rte_spinlock.h>
 
+#include "eal_private.h"
 #include "eal_internal_cfg.h"
 #include "eal_memalloc.h"
 #include "malloc_elem.h"
@@ -42,6 +43,8 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align)
        rte_iova_t expected_iova;
        struct rte_memseg *ms;
        size_t page_sz, cur, max;
+       const struct internal_config *internal_conf =
+               eal_get_internal_configuration();
 
        page_sz = (size_t)elem->msl->page_sz;
        data_start = RTE_PTR_ADD(elem, MALLOC_ELEM_HEADER_LEN);
@@ -60,7 +63,7 @@ malloc_elem_find_max_iova_contig(struct malloc_elem *elem, size_t align)
         */
        if (!elem->msl->external &&
                        (rte_eal_iova_mode() == RTE_IOVA_VA ||
-                               (internal_config.legacy_mem &&
+                               (internal_conf->legacy_mem &&
                                        rte_eal_has_hugepages())))
                return RTE_PTR_DIFF(data_end, contig_seg_start);
 
@@ -171,7 +174,7 @@ malloc_elem_insert(struct malloc_elem *elem)
                next_elem = NULL;
                heap->last = elem;
        } else {
-               /* the new memory is somewhere inbetween start and end */
+               /* the new memory is somewhere between start and end */
                uint64_t dist_from_start, dist_from_end;
 
                dist_from_end = RTE_PTR_DIFF(heap->last, elem);
@@ -340,18 +343,24 @@ remove_elem(struct malloc_elem *elem)
 static int
 next_elem_is_adjacent(struct malloc_elem *elem)
 {
+       const struct internal_config *internal_conf =
+               eal_get_internal_configuration();
+
        return elem->next == RTE_PTR_ADD(elem, elem->size) &&
                        elem->next->msl == elem->msl &&
-                       (!internal_config.match_allocations ||
+                       (!internal_conf->match_allocations ||
                         elem->orig_elem == elem->next->orig_elem);
 }
 
 static int
 prev_elem_is_adjacent(struct malloc_elem *elem)
 {
+       const struct internal_config *internal_conf =
+               eal_get_internal_configuration();
+
        return elem == RTE_PTR_ADD(elem->prev, elem->prev->size) &&
                        elem->prev->msl == elem->msl &&
-                       (!internal_config.match_allocations ||
+                       (!internal_conf->match_allocations ||
                         elem->orig_elem == elem->prev->orig_elem);
 }
 
@@ -382,14 +391,14 @@ malloc_elem_free_list_index(size_t size)
                return 0;
 
        /* Find next power of 2 >= size. */
-       log2 = sizeof(size) * 8 - __builtin_clzl(size-1);
+       log2 = sizeof(size) * 8 - __builtin_clzl(size - 1);
 
        /* Compute freelist index, based on log2(size). */
        index = (log2 - MALLOC_MINSIZE_LOG2 + MALLOC_LOG2_INCREMENT - 1) /
-               MALLOC_LOG2_INCREMENT;
+                       MALLOC_LOG2_INCREMENT;
 
-       return index <= RTE_HEAP_NUM_FREELISTS-1?
-               index: RTE_HEAP_NUM_FREELISTS-1;
+       return index <= RTE_HEAP_NUM_FREELISTS - 1 ?
+                       index : RTE_HEAP_NUM_FREELISTS - 1;
 }
 
 /*