#define _BABELTRACE_COMPAT_MMAN_H
/*
- * babeltrace/compat/mman.h
- *
* Copyright (C) 2015-2016 Michael Jeanson <mjeanson@efficios.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* SOFTWARE.
*/
-#ifndef __MINGW32__
-
-#include <sys/mman.h>
-
-#else /* __MINGW32__ */
+#ifdef __MINGW32__
#include <sys/types.h>
#define MAP_ANON MAP_ANONYMOUS
#define MAP_FAILED ((void *) -1)
-void *mmap(void *addr, size_t length, int prot, int flags, int fd,
+/*
+ * Note that some platforms (e.g. Windows) do not allow read-only
+ * mappings to exceed the file's size (even within a page).
+ */
+void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
off_t offset);
-int munmap(void *addr, size_t length);
+int bt_munmap(void *addr, size_t length);
+
+#else /* __MINGW32__ */
+
+#include <sys/mman.h>
+
+static inline
+void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd,
+ off_t offset)
+{
+ return (void *) mmap(addr, length, prot, flags, fd, offset);
+}
+
+static inline
+int bt_munmap(void *addr, size_t length)
+{
+ return munmap(addr, length);
+}
#endif /* __MINGW32__ */
#ifndef MAP_ANONYMOUS