[w32file] Remove dead code
[mono.git] / mono / utils / mono-mmap-windows-uwp.c
1 /**
2  * \file
3  * UWP dl support for Mono.
4  *
5  * Copyright 2016 Microsoft
6  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
7 */
8 #include <config.h>
9 #include <glib.h>
10 #include "mono/utils/mono-compiler.h"
11
12 #if G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT)
13 #include <windows.h>
14 #include <mono/utils/mono-mmap-windows-internals.h>
15
16 void*
17 mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle)
18 {
19         void *ptr;
20         int mflags = 0;
21         HANDLE file, mapping;
22         int prot = mono_mmap_win_prot_from_flags (flags);
23
24         mflags = FILE_MAP_READ;
25         if (flags & MONO_MMAP_WRITE)
26                 mflags = FILE_MAP_COPY;
27
28         file = (HANDLE) _get_osfhandle (fd);
29         mapping = CreateFileMappingFromApp (file, NULL, prot, length, NULL);
30
31         if (mapping == NULL)
32                 return NULL;
33
34         ptr = MapViewOfFileFromApp (mapping, mflags, offset, length);
35
36         if (ptr == NULL) {
37                 CloseHandle (mapping);
38                 return NULL;
39         }
40
41         *ret_handle = (void*)mapping;
42         return ptr;
43 }
44
45 int
46 mono_file_unmap (void *addr, void *handle)
47 {
48         UnmapViewOfFile (addr);
49         CloseHandle ((HANDLE)handle);
50         return 0;
51 }
52
53 #else /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */
54
55 MONO_EMPTY_SOURCE_FILE (mono_mmap_windows_uwp);
56 #endif /* G_HAVE_API_SUPPORT(HAVE_UWP_WINAPI_SUPPORT) */