mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
update NSPage functions for windows
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30772 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
8f53f101f0
commit
5a58a65949
2 changed files with 8 additions and 7 deletions
|
@ -30,6 +30,7 @@
|
|||
#define EXPOSE_NSInvocation_IVARS 1
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSInvocation.h"
|
||||
#import "Foundation/NSZone.h"
|
||||
#import "GSInvocation.h"
|
||||
|
@ -78,10 +79,8 @@
|
|||
{
|
||||
#if defined(HAVE_MMAP)
|
||||
munmap(buffer, size);
|
||||
#elif defined(__MINGW__)
|
||||
VirtualFree(buffer, 0, MEM_RELEASE);
|
||||
#else
|
||||
#if defined(HAVE_MPROTECT)
|
||||
#if !defined(__MINGW__) && defined(HAVE_MPROTECT)
|
||||
if (mprotect(buffer, NSPageSize(), PROT_READ|PROT_WRITE) == -1)
|
||||
{
|
||||
NSLog(@"Failed to protect memory as writable: %@", [NSError _last]);
|
||||
|
@ -113,8 +112,6 @@
|
|||
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
|
||||
#endif /* HAVE_MPROTECT */
|
||||
if (buffer == (void*)-1) buffer = (void*)0;
|
||||
#elif defined(__MINGW__)
|
||||
buffer = VirtualAlloc(NULL, _size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
#else
|
||||
buffer = NSAllocateMemoryPages(NSPageSize());
|
||||
#endif /* HAVE_MMAP */
|
||||
|
|
|
@ -164,7 +164,9 @@ NSAllocateMemoryPages (NSUInteger bytes)
|
|||
{
|
||||
NSUInteger size = NSRoundUpToMultipleOfPageSize (bytes);
|
||||
void *where;
|
||||
#if __mach__
|
||||
#if defined(__MINGW__)
|
||||
where = VirtualAlloc(NULL, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
#elif __mach__
|
||||
kern_return_t r;
|
||||
r = vm_allocate (mach_task_self(), &where, (vm_size_t) size, 1);
|
||||
if (r != KERN_SUCCESS)
|
||||
|
@ -191,7 +193,9 @@ NSAllocateMemoryPages (NSUInteger bytes)
|
|||
void
|
||||
NSDeallocateMemoryPages (void *ptr, NSUInteger bytes)
|
||||
{
|
||||
#if __mach__
|
||||
#if defined(__MINGW__)
|
||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
#elif __mach__
|
||||
vm_deallocate (mach_task_self (), ptr, NSRoundUpToMultipleOfPageSize (bytes));
|
||||
#else
|
||||
free (ptr);
|
||||
|
|
Loading…
Reference in a new issue