X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Fcompat%2Fmman.h;h=33febccbb1c1e760c601a821ed6d3522e9e2bebe;hp=9f494526617469f5292a7341ee803a5ab26c9cda;hb=HEAD;hpb=578e048b5debf169e286e5b5cc747b5d6c16886d diff --git a/src/compat/mman.h b/src/compat/mman.h index 9f494526..33febccb 100644 --- a/src/compat/mman.h +++ b/src/compat/mman.h @@ -1,31 +1,16 @@ -#ifndef _BABELTRACE_COMPAT_MMAN_H -#define _BABELTRACE_COMPAT_MMAN_H - /* - * Copyright (C) 2015-2016 Michael Jeanson - * - * 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 (C) 2015-2016 Michael Jeanson */ +#ifndef _BABELTRACE_COMPAT_MMAN_H +#define _BABELTRACE_COMPAT_MMAN_H + #ifdef __MINGW32__ #include +#include "common/macros.h" #define PROT_NONE 0x0 #define PROT_READ 0x1 @@ -45,20 +30,27 @@ * Note that some platforms (e.g. Windows) do not allow read-only * mappings to exceed the file's size (even within a page). */ -void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd, - off_t offset); +BT_EXTERN_C void *bt_mmap(size_t length, int prot, int flags, int fd, + off_t offset, int log_level); -int bt_munmap(void *addr, size_t length); +BT_EXTERN_C int bt_munmap(void *addr, size_t length); + +/* + * On Windows the memory mapping offset must be aligned to the memory + * allocator allocation granularity and not the page size. + */ +BT_EXTERN_C size_t bt_mmap_get_offset_align_size(int log_level); #else /* __MINGW32__ */ #include +#include "common/common.h" static inline -void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd, - off_t offset) +void *bt_mmap(size_t length, int prot, int flags, int fd, + off_t offset, int log_level __attribute__((unused))) { - return (void *) mmap(addr, length, prot, flags, fd, offset); + return (void *) mmap(NULL, length, prot, flags, fd, offset); } static inline @@ -66,6 +58,16 @@ int bt_munmap(void *addr, size_t length) { return munmap(addr, length); } + +/* + * On other platforms the memory mapping offset must be aligned to the + * page size. + */ +static inline +size_t bt_mmap_get_offset_align_size(int log_level) +{ + return bt_common_get_page_size(log_level); +} #endif /* __MINGW32__ */ #ifndef MAP_ANONYMOUS