diff options
Diffstat (limited to '')
-rw-r--r-- | src/nxt_mem_map.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/nxt_mem_map.c b/src/nxt_mem_map.c new file mode 100644 index 00000000..f9caf54f --- /dev/null +++ b/src/nxt_mem_map.c @@ -0,0 +1,40 @@ + +/* + * Copyright (C) Igor Sysoev + * Copyright (C) NGINX, Inc. + */ + +#include <nxt_main.h> + + +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) +{ + void *p; + + p = mmap(addr, len, protection, flags, fd, offset); + + if (nxt_fast_path(p != MAP_FAILED)) { + nxt_thread_log_debug("mmap(%p, %uz, %uxi, %uxi, %FD, %O): %p", + addr, len, protection, flags, fd, offset, p); + + } else { + nxt_thread_log_alert("mmap(%p, %uz, %ui, %ui, %FD, %O) failed %E", + addr, len, protection, flags, fd, offset, nxt_errno); + } + + return p; +} + + +void +nxt_mem_munmap(void *addr, size_t len) +{ + if (nxt_fast_path(munmap(addr, len) == 0)) { + nxt_thread_log_debug("munmap(%p, %uz)", addr, len); + + } else { + nxt_thread_log_alert("munmap(%p, %uz) failed %E", addr, len, nxt_errno); + } +} |