d16dea0b98babb57b5c055e18a3e0f5d22e5d78e
[pcsx_rearmed.git] / libpcsxcore / memmap.h
1 /* Copyright  (C) 2010-2020 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (memmap.h).
5  * ---------------------------------------------------------------------------------------
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22
23 #ifndef _MEMMAP_H
24 #define _MEMMAP_H
25
26 #ifdef _WIN32
27
28 #ifndef _WIN32_WINNT            /* Allow use of features specific to Windows XP or later. */
29 #define _WIN32_WINNT 0x0501     /* Change this to the appropriate value to target other versions of Windows. */
30 #endif                                          
31
32 /* All the headers include this file. */
33 #ifndef _MSC_VER
34 #include <_mingw.h>
35 #endif
36
37 #endif //_WIN32
38
39 #if defined(_WIN32) || !P_HAVE_MMAP
40 #include <sys/types.h>
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 #define PROT_NONE       0
47 #define PROT_READ       1
48 #define PROT_WRITE      2
49 #define PROT_EXEC       4
50
51 #define MAP_FILE        0
52 #define MAP_SHARED      1
53 #define MAP_PRIVATE     2
54 #define MAP_TYPE        0xf
55 #define MAP_FIXED       0x10
56 #define MAP_ANONYMOUS   0x20
57 #define MAP_ANON        MAP_ANONYMOUS
58
59 #define MAP_FAILED      ((void *)-1)
60
61 /* Flags for msync. */
62 #define MS_ASYNC        1
63 #define MS_SYNC         2
64 #define MS_INVALIDATE   4
65
66 #ifdef _WIN32
67 void*   mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off);
68 int     munmap(void *addr, size_t len);
69 int     mprotect(void *addr, size_t len, int prot);
70 int     msync(void *addr, size_t len, int flags);
71 int     mlock(const void *addr, size_t len);
72 int     munlock(const void *addr, size_t len);
73 #endif
74
75 #ifdef __cplusplus
76 };
77 #endif
78
79 #else
80 #include <sys/mman.h>
81 #endif
82
83 #endif