aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.h1
-rw-r--r--lib/xwrap.c7
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/lib.h b/lib/lib.h
index effba9b4..0b93bde9 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -115,6 +115,7 @@ void xstrncpy(char *dest, char *src, size_t size);
void xstrncat(char *dest, char *src, size_t size);
void _xexit(void) noreturn;
void xexit(void) noreturn;
+void *xmmap(void *addr, size_t length, int prot, int flags, int fd, off_t off);
void *xmalloc(size_t size);
void *xzalloc(size_t size);
void *xrealloc(void *ptr, size_t size);
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 0281e701..83f54a0a 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -58,6 +58,13 @@ void xexit(void)
_xexit();
}
+void *xmmap(void *addr, size_t length, int prot, int flags, int fd, off_t off)
+{
+ void *ret = mmap(addr, length, prot, flags, fd, off);
+ if (ret == MAP_FAILED) perror_exit("mmap");
+ return ret;
+}
+
// Die unless we can allocate memory.
void *xmalloc(size_t size)
{