Zycore 1.4.0.0
Loading...
Searching...
No Matches
Memory.h
Go to the documentation of this file.
1/***************************************************************************************************
2
3 Zyan Core Library (Zycore-C)
4
5 Original Author : Florian Bernd
6
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24
25***************************************************************************************************/
26
32#ifndef ZYCORE_API_MEMORY_H
33#define ZYCORE_API_MEMORY_H
34
35#include <Zycore/Defines.h>
36#include <Zycore/Status.h>
37#include <Zycore/Types.h>
38
39#ifndef ZYAN_NO_LIBC
40
41#if defined(ZYAN_WINDOWS)
42# include <windows.h>
43#elif defined(ZYAN_POSIX)
44# include <sys/mman.h>
45#else
46# error "Unsupported platform detected"
47#endif
48
49/* ============================================================================================== */
50/* Enums and types */
51/* ============================================================================================== */
52
57{
58#if defined(ZYAN_WINDOWS)
59
60 ZYAN_PAGE_READONLY = PAGE_READONLY,
61 ZYAN_PAGE_READWRITE = PAGE_READWRITE,
62 ZYAN_PAGE_EXECUTE = PAGE_EXECUTE,
63 ZYAN_PAGE_EXECUTE_READ = PAGE_EXECUTE_READ,
64 ZYAN_PAGE_EXECUTE_READWRITE = PAGE_EXECUTE_READWRITE
65
66#elif defined(ZYAN_POSIX)
67
68 ZYAN_PAGE_READONLY = PROT_READ,
69 ZYAN_PAGE_READWRITE = PROT_READ | PROT_WRITE,
70 ZYAN_PAGE_EXECUTE = PROT_EXEC,
71 ZYAN_PAGE_EXECUTE_READ = PROT_EXEC | PROT_READ,
72 ZYAN_PAGE_EXECUTE_READWRITE = PROT_EXEC | PROT_READ | PROT_WRITE
73
74#endif
76
77/* ============================================================================================== */
78/* Exported functions */
79/* ============================================================================================== */
80
81/* ---------------------------------------------------------------------------------------------- */
82/* General */
83/* ---------------------------------------------------------------------------------------------- */
84
91
104
105/* ---------------------------------------------------------------------------------------------- */
106/* Memory management */
107/* ---------------------------------------------------------------------------------------------- */
108
119 ZyanMemoryPageProtection protection);
120
129ZYCORE_EXPORT ZyanStatus ZyanMemoryVirtualFree(void* address, ZyanUSize size);
130
131/* ---------------------------------------------------------------------------------------------- */
132
133/* ============================================================================================== */
134
135#endif /* ZYAN_NO_LIBC */
136
137#endif /* ZYCORE_API_MEMORY_H */
#define ZYCORE_EXPORT
Definition Defines.h:227
ZYCORE_EXPORT ZyanStatus ZyanMemoryVirtualFree(void *address, ZyanUSize size)
ZYCORE_EXPORT ZyanU32 ZyanMemoryGetSystemAllocationGranularity()
ZYCORE_EXPORT ZyanU32 ZyanMemoryGetSystemPageSize()
ZYCORE_EXPORT ZyanStatus ZyanMemoryVirtualProtect(void *address, ZyanUSize size, ZyanMemoryPageProtection protection)
ZyanMemoryPageProtection_
Definition Memory.h:57
enum ZyanMemoryPageProtection_ ZyanMemoryPageProtection
ZyanU32 ZyanStatus
Definition Status.h:48