diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-01-17 20:00:00 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-01-17 20:00:00 +0300 |
commit | 16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch) | |
tree | e6530480020f62a2bdbf249988ec3e2a751d3927 /src/nxt_mem_map.c | |
download | unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2 |
Initial version.
Diffstat (limited to 'src/nxt_mem_map.c')
-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); + } +} |