b33ca61169147c9375e9f8233ac0a60a833a5818
2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2015-2016 Michael Jeanson <mjeanson@efficios.com>
7 #ifndef BABELTRACE_COMPAT_MMAN_H
8 #define BABELTRACE_COMPAT_MMAN_H
12 #include <sys/types.h>
13 #include "common/macros.h"
17 #define PROT_WRITE 0x2
24 #define MAP_FIXED 0x10
25 #define MAP_ANONYMOUS 0x20
26 #define MAP_ANON MAP_ANONYMOUS
27 #define MAP_FAILED ((void *) -1)
30 * Note that some platforms (e.g. Windows) do not allow read-only
31 * mappings to exceed the file's size (even within a page).
33 BT_EXTERN_C
void *bt_mmap(size_t length
, int prot
, int flags
, int fd
,
34 off_t offset
, int log_level
);
36 BT_EXTERN_C
int bt_munmap(void *addr
, size_t length
);
39 * On Windows the memory mapping offset must be aligned to the memory
40 * allocator allocation granularity and not the page size.
42 BT_EXTERN_C
size_t bt_mmap_get_offset_align_size(int log_level
);
44 #else /* __MINGW32__ */
47 #include "common/common.h"
50 void *bt_mmap(size_t length
, int prot
, int flags
, int fd
,
51 off_t offset
, int log_level
__attribute__((unused
)))
53 return (void *) mmap(NULL
, length
, prot
, flags
, fd
, offset
);
57 int bt_munmap(void *addr
, size_t length
)
59 return munmap(addr
, length
);
63 * On other platforms the memory mapping offset must be aligned to the
67 size_t bt_mmap_get_offset_align_size(int log_level
)
69 return bt_common_get_page_size(log_level
);
71 #endif /* __MINGW32__ */
75 # define MAP_ANONYMOUS MAP_ANON
79 #endif /* BABELTRACE_COMPAT_MMAN_H */
This page took 0.03364 seconds and 5 git commands to generate.