summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_mem_map.h
blob: a4a10cc40ff171c46406e43be7f419f1d51e0b09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */

#ifndef _NXT_UNIX_MEM_MAP_H_INCLUDED_
#define _NXT_UNIX_MEM_MAP_H_INCLUDED_


#define NXT_MEM_MAP_FAILED    MAP_FAILED


#define NXT_MEM_MAP_READ      PROT_READ
#define NXT_MEM_MAP_WRITE     PROT_WRITE


#if (NXT_HAVE_MAP_ANONYMOUS)
#define NXT_MEM_MAP_ANON      MAP_ANONYMOUS
#else
#define NXT_MEM_MAP_ANON      MAP_ANON
#endif

#define NXT_MEM_MAP_SHARED    (MAP_SHARED | NXT_MEM_MAP_ANON)


#if (NXT_HAVE_MAP_POPULATE)
/*
 * Linux MAP_POPULATE reads ahead and wires pages.
 * (MAP_POPULATE | MAP_NONBLOCK) wires only resident pages
 * without read ahead but it does not work since Linux 2.6.23.
 */
#define NXT_MEM_MAP_PREFAULT  MAP_POPULATE

#elif (NXT_HAVE_MAP_PREFAULT_READ)
/* FreeBSD MAP_PREFAULT_READ wires resident pages without read ahead. */
#define NXT_MEM_MAP_PREFAULT  MAP_PREFAULT_READ

#else
#define NXT_MEM_MAP_PREFAULT  0
#endif

#define NXT_MEM_MAP_FILE      (MAP_SHARED | NXT_MEM_MAP_PREFAULT)


#define                                                                       \
    nxt_mem_map_file_ctx_t(ctx)


#define                                                                       \
nxt_mem_map(addr, ctx, len, protection, flags, fd, offset)                    \
    nxt_mem_mmap(addr, len, protection, flags, fd, offset)


#define                                                                       \
nxt_mem_unmap(addr, ctx, len)                                                 \
    nxt_mem_munmap(addr, len)


NXT_EXPORT void *nxt_mem_mmap(void *addr, size_t len, nxt_uint_t protection,
    nxt_uint_t flags, nxt_fd_t fd, nxt_off_t offset);
NXT_EXPORT void nxt_mem_munmap(void *addr, size_t len);


#endif /* _NXT_UNIX_MEM_MAP_H_INCLUDED_ */