port: mmap offset alignment on Windows
[babeltrace.git] / src / common / mmap-align.h
index 033d6c4a92916ce651fc14590887c52d46d82d5b..c42cdeb34da234b02490db1f0cf25c6fe877893f 100644 (file)
@@ -46,29 +46,11 @@ struct mmap_align {
        size_t length;                  /* virtual mmap length */
 };
 
-#ifdef __WIN32__
-#include <windows.h>
-
-/*
- * On windows the memory mapping offset must be aligned to the memory
- * allocator allocation granularity and not the page size.
- */
-static inline
-off_t get_page_aligned_offset(off_t offset, size_t page_size)
-{
-       SYSTEM_INFO sysinfo;
-
-       GetNativeSystemInfo(&sysinfo);
-
-       return ALIGN_FLOOR(offset, sysinfo.dwAllocationGranularity);
-}
-#else
 static inline
-off_t get_page_aligned_offset(off_t offset, size_t page_size)
+off_t get_page_aligned_offset(off_t offset, int log_level)
 {
-       return ALIGN_FLOOR(offset, page_size);
+       return ALIGN_FLOOR(offset, bt_mmap_get_offset_align_size(log_level));
 }
-#endif
 
 static inline
 struct mmap_align *mmap_align(size_t length, int prot,
@@ -84,7 +66,7 @@ struct mmap_align *mmap_align(size_t length, int prot,
        if (!mma)
                return MAP_FAILED;
        mma->length = length;
-       page_aligned_offset = get_page_aligned_offset(offset, page_size);
+       page_aligned_offset = get_page_aligned_offset(offset, log_level);
        /*
         * Page aligned length needs to contain the requested range.
         * E.g., for a small range that fits within a single page, we might
This page took 0.02391 seconds and 4 git commands to generate.