Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorJeroen Vermeulen <jtv@precisiontranslationtools.com>2015-04-17 14:53:46 +0300
committerJeroen Vermeulen <jtv@precisiontranslationtools.com>2015-04-17 14:53:46 +0300
commit1e3e445e3f06c7f25edd1c6150a8e39e0db07249 (patch)
tree36c0b2ad07a8395535bb765672b49dacd62f3e80 /util
parent6a4943ca41efd71d9039fc9491d202a78a81cc8f (diff)
Use cross-platform mmap() wrapper in CompactPT.
The MmapAllocator header made use of sys/mman.h and mmap(), which are Unix-specific. But util has a wrapper which also works on Windows. This also fixes the error handling: when mmap() failed, the old code would return an invalid (but non-NULL!) pointer — leading to a crash. The wrapper will throw an exception with a helpful error message.
Diffstat (limited to 'util')
-rw-r--r--util/mmap.hh5
1 files changed, 4 insertions, 1 deletions
diff --git a/util/mmap.hh b/util/mmap.hh
index 9b1e120f3..37feb5bee 100644
--- a/util/mmap.hh
+++ b/util/mmap.hh
@@ -100,9 +100,12 @@ typedef enum {
extern const int kFileFlags;
-// Wrapper around mmap to check it worked and hide some platform macros.
+// Cross-platform, error-checking wrapper for mmap().
void *MapOrThrow(std::size_t size, bool for_write, int flags, bool prefault, int fd, uint64_t offset = 0);
+// Cross-platform, error-checking wrapper for munmap().
+void UnmapOrThrow(void *start, size_t length);
+
void MapRead(LoadMethod method, int fd, uint64_t offset, std::size_t size, scoped_memory &out);
void MapAnonymous(std::size_t size, scoped_memory &to);