summaryrefslogtreecommitdiff
path: root/src/os_win/os_map.c
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2014-10-08 19:46:48 -0400
committerMark Benvenuto <mark.benvenuto@mongodb.com>2014-10-08 20:11:26 -0400
commitd20905d154cdfa4c519231ab0860a86442b6ce71 (patch)
tree39ca2dbe5334d0f903e55558870672c29b92127f /src/os_win/os_map.c
parentb253daad8208deea209fb203e80a7bbe4098849f (diff)
downloadmongo-d20905d154cdfa4c519231ab0860a86442b6ce71.tar.gz
Initial Windows Port
Diffstat (limited to 'src/os_win/os_map.c')
-rw-r--r--src/os_win/os_map.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/os_win/os_map.c b/src/os_win/os_map.c
new file mode 100644
index 00000000000..105cf47dd51
--- /dev/null
+++ b/src/os_win/os_map.c
@@ -0,0 +1,92 @@
+/*-
+ * Copyright (c) 2008-2014 WiredTiger, Inc.
+ * All rights reserved.
+ *
+ * See the file LICENSE for redistribution information.
+ */
+
+#include "wt_internal.h"
+
+/*
+ * __wt_mmap --
+ * Map a file into memory.
+ */
+int
+__wt_mmap(WT_SESSION_IMPL *session, WT_FH *fh, void *mapp, size_t *lenp,
+ void** mappingcookie)
+{
+ void *map;
+
+ WT_RET(__wt_verbose(session, WT_VERB_FILEOPS,
+ "%s: MapViewOfFile %" PRIuMAX " bytes", fh->name, (uintmax_t)fh->size));
+
+ *mappingcookie = CreateFileMapping(fh->filehandle, NULL, PAGE_READONLY, 0, 0, NULL);
+ if (*mappingcookie == NULL)
+ WT_RET_MSG(session, __wt_errno(),
+ "%s CreateFileMapping error: failed to map %" PRIuMAX " bytes",
+ fh->name, (uintmax_t)fh->size);
+
+ if ((map = MapViewOfFile(*mappingcookie, FILE_MAP_READ, 0, 0, fh->size)) == NULL) {
+ CloseHandle(*mappingcookie);
+ *mappingcookie = NULL;
+
+ WT_RET_MSG(session, __wt_errno(),
+ "%s map error: failed to map %" PRIuMAX " bytes",
+ fh->name, (uintmax_t)fh->size);
+ }
+
+ *(void **)mapp = map;
+ *lenp = (size_t)fh->size;
+ return (0);
+}
+
+/*
+ * __wt_mmap_preload --
+ * Cause a section of a memory map to be faulted in.
+ */
+int
+__wt_mmap_preload(WT_SESSION_IMPL *session, const void *p, size_t size)
+{
+ WT_UNUSED(session);
+ WT_UNUSED(p);
+ WT_UNUSED(size);
+
+ return (0);
+}
+
+/*
+ * __wt_mmap_discard --
+ * Discard a chunk of the memory map.
+ */
+int
+__wt_mmap_discard(WT_SESSION_IMPL *session, void *p, size_t size)
+{
+ WT_UNUSED(session);
+ WT_UNUSED(p);
+ WT_UNUSED(size);
+ return (0);
+}
+
+/*
+ * __wt_munmap --
+ * Remove a memory mapping.
+ */
+int
+__wt_munmap(WT_SESSION_IMPL *session, WT_FH *fh, void *map, size_t len,
+ void** mappingcookie)
+{
+ WT_RET(__wt_verbose(session, WT_VERB_FILEOPS,
+ "%s: UnmapViewOfFile %" PRIuMAX " bytes", fh->name, (uintmax_t)len));
+
+ if (UnmapViewOfFile(map) == 0) {
+ WT_RET_MSG(session, __wt_errno(),
+ "%s UnmapViewofFile error: failed to unmap %" PRIuMAX " bytes",
+ fh->name, (uintmax_t)len);
+ }
+
+ CloseHandle(*mappingcookie);
+
+ *mappingcookie = 0;
+
+ return (0);
+}