doc: add Meson coding style to contributors guide
[dpdk.git] / lib / librte_eal / common / eal_common_fbarray.c
index fd0292a..3a28a53 100644 (file)
@@ -81,9 +81,8 @@ get_used_mask(void *data, unsigned int elt_sz, unsigned int len)
 }
 
 static int
-resize_and_map(int fd, void *addr, size_t len)
+resize_and_map(int fd, const char *path, void *addr, size_t len)
 {
-       char path[PATH_MAX];
        void *map_addr;
 
        if (eal_file_truncate(fd, len)) {
@@ -110,7 +109,7 @@ overlap(const struct mem_area *ma, const void *start, size_t len)
        if (start >= ma_start && start < ma_end)
                return 1;
        /* end overlap? */
-       if (end >= ma_start && end < ma_end)
+       if (end > ma_start && end < ma_end)
                return 1;
        return 0;
 }
@@ -139,7 +138,7 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
         */
        last = MASK_LEN_TO_IDX(arr->len);
        last_mod = MASK_LEN_TO_MOD(arr->len);
-       last_msk = ~(-1ULL << last_mod);
+       last_msk = ~(UINT64_MAX << last_mod);
 
        for (msk_idx = first; msk_idx < msk->n_masks; msk_idx++) {
                uint64_t cur_msk, lookahead_msk;
@@ -399,8 +398,8 @@ find_prev_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
        first_mod = MASK_LEN_TO_MOD(start);
        /* we're going backwards, so mask must start from the top */
        ignore_msk = first_mod == MASK_ALIGN - 1 ?
-                               -1ULL : /* prevent overflow */
-                               ~(-1ULL << (first_mod + 1));
+                               UINT64_MAX : /* prevent overflow */
+                               ~(UINT64_MAX << (first_mod + 1));
 
        /* go backwards, include zero */
        msk_idx = first;
@@ -514,7 +513,7 @@ find_prev_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
                                 * no runs in the space we've lookbehind-scanned
                                 * as well, so skip that on next iteration.
                                 */
-                               ignore_msk = -1ULL << need;
+                               ignore_msk = UINT64_MAX << need;
                                msk_idx = lookbehind_idx;
                                break;
                        }
@@ -561,8 +560,8 @@ find_prev(const struct rte_fbarray *arr, unsigned int start, bool used)
        first_mod = MASK_LEN_TO_MOD(start);
        /* we're going backwards, so mask must start from the top */
        ignore_msk = first_mod == MASK_ALIGN - 1 ?
-                               -1ULL : /* prevent overflow */
-                               ~(-1ULL << (first_mod + 1));
+                               UINT64_MAX : /* prevent overflow */
+                               ~(UINT64_MAX << (first_mod + 1));
 
        /* go backwards, include zero */
        idx = first;
@@ -715,6 +714,8 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,
        struct mem_area *ma = NULL;
        void *data = NULL;
        int fd = -1;
+       const struct internal_config *internal_conf =
+               eal_get_internal_configuration();
 
        if (arr == NULL) {
                rte_errno = EINVAL;
@@ -750,7 +751,7 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,
 
        fd = -1;
 
-       if (internal_config.no_shconf) {
+       if (internal_conf->no_shconf) {
                /* remap virtual area as writable */
                static const int flags = RTE_MAP_FORCE_ADDRESS |
                        RTE_MAP_PRIVATE | RTE_MAP_ANONYMOUS;
@@ -790,7 +791,7 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,
                if (eal_file_lock(fd, EAL_FLOCK_SHARED, EAL_FLOCK_RETURN))
                        goto fail;
 
-               if (resize_and_map(fd, data, mmap_len))
+               if (resize_and_map(fd, path, data, mmap_len))
                        goto fail;
        }
        ma->addr = data;
@@ -893,7 +894,7 @@ rte_fbarray_attach(struct rte_fbarray *arr)
        if (eal_file_lock(fd, EAL_FLOCK_SHARED, EAL_FLOCK_RETURN))
                goto fail;
 
-       if (resize_and_map(fd, data, mmap_len))
+       if (resize_and_map(fd, path, data, mmap_len))
                goto fail;
 
        /* store our new memory area */
@@ -977,6 +978,8 @@ rte_fbarray_destroy(struct rte_fbarray *arr)
        size_t mmap_len;
        int fd, ret;
        char path[PATH_MAX];
+       const struct internal_config *internal_conf =
+               eal_get_internal_configuration();
 
        if (arr == NULL) {
                rte_errno = EINVAL;
@@ -1010,7 +1013,7 @@ rte_fbarray_destroy(struct rte_fbarray *arr)
                goto out;
        }
        /* with no shconf, there were never any files to begin with */
-       if (!internal_config.no_shconf) {
+       if (!internal_conf->no_shconf) {
                /*
                 * attempt to get an exclusive lock on the file, to ensure it
                 * has been detached by all other processes