1 2 /* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7 #ifndef _NXT_UNIX_MEM_MAP_H_INCLUDED_ 8 #define _NXT_UNIX_MEM_MAP_H_INCLUDED_ 9 10 11 #define NXT_MEM_MAP_FAILED MAP_FAILED 12 13 14 #define NXT_MEM_MAP_READ PROT_READ 15 #define NXT_MEM_MAP_WRITE PROT_WRITE 16 17 18 #if (NXT_HAVE_MAP_ANONYMOUS) 19 #define NXT_MEM_MAP_ANON MAP_ANONYMOUS 20 #else 21 #define NXT_MEM_MAP_ANON MAP_ANON 22 #endif 23 24 #define NXT_MEM_MAP_SHARED (MAP_SHARED | NXT_MEM_MAP_ANON) 25 26 27 #if (NXT_HAVE_MAP_POPULATE) 28 /* 29 * Linux MAP_POPULATE reads ahead and wires pages. 30 * (MAP_POPULATE | MAP_NONBLOCK) wires only resident pages 31 * without read ahead but it does not work since Linux 2.6.23. 32 */ 33 #define NXT_MEM_MAP_PREFAULT MAP_POPULATE 34 35 #elif (NXT_HAVE_MAP_PREFAULT_READ) 36 /* FreeBSD MAP_PREFAULT_READ wires resident pages without read ahead. */ 37 #define NXT_MEM_MAP_PREFAULT MAP_PREFAULT_READ 38 39 #else 40 #define NXT_MEM_MAP_PREFAULT 0 41 #endif 42 43 #define NXT_MEM_MAP_FILE (MAP_SHARED | NXT_MEM_MAP_PREFAULT) 44 45 46 #define \ 47 nxt_mem_map_file_ctx_t(ctx) 48 49 50 #define \ 51 nxt_mem_map(addr, ctx, len, protection, flags, fd, offset) \ 52 nxt_mem_mmap(addr, len, protection, flags, fd, offset) 53 54 55 #define \ 56 nxt_mem_unmap(addr, ctx, len) \ 57 nxt_mem_munmap(addr, len) 58 59 60 NXT_EXPORT void *nxt_mem_mmap(void *addr, size_t len, nxt_uint_t protection, 61 nxt_uint_t flags, nxt_fd_t fd, nxt_off_t offset); 62 NXT_EXPORT void nxt_mem_munmap(void *addr, size_t len); 63 64 65 #endif /* _NXT_UNIX_MEM_MAP_H_INCLUDED_ */ 66