Port: Add bt_common_get_page_size
[babeltrace.git] / include / babeltrace / mmap-align-internal.h
index d89affb592884a67f64507eee31c0493043891ae..0667ab0c8933ad7a8db91c659fd0977c3294ae9e 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <stdint.h>
 #include <sys/mman.h>
+#include <babeltrace/common-internal.h>
 
 /*
  * This header implements a wrapper over mmap (mmap_align) that memory
@@ -53,19 +54,22 @@ struct mmap_align *mmap_align(size_t length, int prot,
 {
        struct mmap_align *mma;
        off_t page_aligned_offset;      /* mmap offset, aligned to floor */
+       size_t page_size;
+
+       page_size = bt_common_get_page_size();
 
        mma = malloc(sizeof(*mma));
        if (!mma)
                return MAP_FAILED;
        mma->length = length;
-       page_aligned_offset = ALIGN_FLOOR(offset, PAGE_SIZE);
+       page_aligned_offset = ALIGN_FLOOR(offset, page_size);
        /*
         * Page aligned length needs to contain the requested range.
         * E.g., for a small range that fits within a single page, we might
         * require a 2 pages page_aligned_length if the range crosses a page
         * boundary.
         */
-       mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, PAGE_SIZE);
+       mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, page_size);
        mma->page_aligned_addr = mmap(NULL, mma->page_aligned_length,
                prot, flags, fd, page_aligned_offset);
        if (mma->page_aligned_addr == (void *) -1UL) {
This page took 0.023595 seconds and 4 git commands to generate.