1.1 --- a/jitcraft/Platform-Windows.cpp Mon Jul 02 14:04:29 2012 -0700
1.2 +++ b/jitcraft/Platform-Windows.cpp Mon Jul 02 23:37:12 2012 -0700
1.3 @@ -1,19 +1,20 @@
1.4 -/*
1.5 - * Copyright (C) 2012 David Anderson
1.6 - *
1.7 - * This file is part of JITCraft.
1.8 - *
1.9 - * JITCraft is free software: you can redistribute it and/or modify it under
1.10 - * the terms of the GNU General Public License as published by the Free
1.11 - * Software Foundation, either version 3 of the License, or (at your option)
1.12 - * any later version.
1.13 - *
1.14 - * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
1.15 - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.16 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1.17 - *
1.18 - * You should have received a copy of the GNU General Public License along with
1.19 - * JITCraft. If not, see http://www.gnu.org/licenses/.
1.20 +/* vim: set ts=4 sw=4 tw=99 et:
1.21 + *
1.22 + * Copyright (C) 2012 David Anderson
1.23 + *
1.24 + * This file is part of JITCraft.
1.25 + *
1.26 + * JITCraft is free software: you can redistribute it and/or modify it under
1.27 + * the terms of the GNU General Public License as published by the Free
1.28 + * Software Foundation, either version 3 of the License, or (at your option)
1.29 + * any later version.
1.30 + *
1.31 + * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
1.32 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.33 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1.34 + *
1.35 + * You should have received a copy of the GNU General Public License along with
1.36 + * JITCraft. If not, see http://www.gnu.org/licenses/.
1.37 */
1.38
1.39 // :TODO: move into utility-style include
1.40 @@ -27,7 +28,7 @@
1.41 ToProtBits(OS::Protection prot)
1.42 {
1.43 switch (prot) {
1.44 - case OS::Prot_ReadWrite:
1.45 + case OS::Prot_ReadWrite:
1.46 return PAGE_READWRITE;
1.47 case OS::Prot_ReadWriteExecute:
1.48 return PAGE_EXECUTE_READWRITE;
1.49 @@ -61,6 +62,22 @@
1.50 VirtualFree(address, 0, MEM_RELEASE);
1.51 }
1.52
1.53 +static Address
1.54 +MapMemoryAt(Address address, size_t amount, MapMode mode, Protection prot_)
1.55 +{
1.56 + DWORD bits = ToProtBits(prot_);
1.57 + DWORD flags = MEM_RESERVE;
1.58 + if (mode == Map_Commit)
1.59 + flags |= MEM_COMMIT;
1.60 +
1.61 + Address x = (Address)VirtualAlloc((LPVOID)address, amount, flags, bits);
1.62 + if (!x) {
1.63 + DWORD err = GetLastError();
1.64 + return x;
1.65 + }
1.66 + return x;
1.67 +}
1.68 +
1.69 OS::AlignableMapping
1.70 OS::MapAlignedMemory(size_t amount, size_t alignment, MapMode mode)
1.71 {
1.72 @@ -92,22 +109,6 @@
1.73 return AlignableMapping(addr, alignment, amount);
1.74 }
1.75
1.76 -Address
1.77 -OS::MapMemoryAt(Address address, size_t amount, MapMode mode, Protection prot_)
1.78 -{
1.79 - DWORD bits = ToProtBits(prot_);
1.80 - DWORD flags = MEM_RESERVE;
1.81 - if (mode == Map_Commit)
1.82 - flags |= MEM_COMMIT;
1.83 -
1.84 - Address x = (Address)VirtualAlloc((LPVOID)address, amount, flags, bits);
1.85 - if (!x) {
1.86 - DWORD err = GetLastError();
1.87 - return x;
1.88 - }
1.89 - return x;
1.90 -}
1.91 -
1.92 void
1.93 OS::UnmapAlignedMemory(Address address, size_t size)
1.94 {