Implement ++ and -- operators.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jitcraft_platform_h_
19 #define _include_jitcraft_platform_h_
27 Prot_ReadWrite, // rw-, for the heap
28 Prot_ReadExecute, // r-x, for code
29 Prot_ReadWriteExecute // rwx, if disabling r-x for code.
33 Map_Reserve, // don't ask for actual pages yet
34 Map_Commit // ask for pages right away
37 Address MapMemory(size_t amount, MapMode mode, Protection prot);
38 bool CommitMemory(Address address, size_t amount, Protection prot);
39 void UnmapMemory(Address address, size_t size);
41 class AlignableMapping {
47 AlignableMapping(Address ptr, size_t alignment, size_t size)
52 if (!IsAligned(aligned_, alignment))
53 aligned_ = AlignedBase(aligned_, alignment) + alignment;
56 AlignableMapping() : base_(NULL), aligned_(NULL), size_(0)
60 Address base() const {
63 bool isValid() const {
69 Address aligned() const {
74 AlignableMapping MapAlignedMemory(size_t amount, size_t alignment, MapMode mode);
75 void UnmapAlignedMemory(Address address, size_t size);
77 // The default alignment of memory returned via MapMemory().
78 // :TODO: better ifdefs
80 static const size_t kMapAlignment = 64 * kKB;
82 static const size_t kMapAlignment = 4 * kKB;
85 // Internal OS:: use only.
86 Address MapMemoryAt(Address address, size_t amount, MapMode mode, Protection prot);
87 AlignableMapping Shared_MapAlignableMemory(size_t amount, size_t alignment, MapMode mode);
92 #endif // _include_jitcraft_platform_h_