Move to kernel style SPDX license identifiers
[babeltrace.git] / src / common / mmap-align.h
index 5d91c03523f240c47623a216ea8532b21cf3cb5c..05ade732ba6291ff1f3ce6a169b962797e487757 100644 (file)
@@ -1,28 +1,12 @@
-#ifndef _BABELTRACE_MMAP_ALIGN_H
-#define _BABELTRACE_MMAP_ALIGN_H
-
 /*
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * SPDX-License-Identifier: MIT
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Copyright 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  */
 
+#ifndef _BABELTRACE_MMAP_ALIGN_H
+#define _BABELTRACE_MMAP_ALIGN_H
+
 #include "common/align.h"
 #include <stdlib.h>
 #include <stdint.h>
@@ -46,29 +30,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 +50,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
@@ -93,7 +59,7 @@ struct mmap_align *mmap_align(size_t length, int prot,
         */
        mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, page_size);
        mma->page_aligned_addr = bt_mmap(NULL, mma->page_aligned_length,
-               prot, flags, fd, page_aligned_offset);
+               prot, flags, fd, page_aligned_offset, log_level);
        if (mma->page_aligned_addr == MAP_FAILED) {
                free(mma);
                return MAP_FAILED;
This page took 0.024986 seconds and 4 git commands to generate.