mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 20:26:42 +00:00
minor portability improvement
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30726 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4a7ab91a44
commit
ddb072851c
2 changed files with 10 additions and 4 deletions
|
@ -31,6 +31,7 @@
|
|||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSInvocation.h"
|
||||
#import "Foundation/NSZone.h"
|
||||
#import "GSInvocation.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
@ -81,7 +82,7 @@
|
|||
VirtualFree(buffer, 0, MEM_RELEASE);
|
||||
#else
|
||||
#if defined(HAVE_MPROTECT)
|
||||
if (mprotect(buffer,sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE) == -1)
|
||||
if (mprotect(buffer, NSPageSize(), PROT_READ|PROT_WRITE) == -1)
|
||||
{
|
||||
NSLog(@"Failed to protect memory as writable: %@", [NSError _last]);
|
||||
}
|
||||
|
@ -114,8 +115,8 @@
|
|||
buffer = VirtualAlloc(NULL, _size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
#else
|
||||
// buffer = malloc(_size);
|
||||
NSAssert(_size < sysconf(_SC_PAGESIZE), @"Tried to allocate more than one page.");
|
||||
buffer = valloc(sysconf(_SC_PAGESIZE));
|
||||
NSAssert(_size < NSPageSize(), @"Tried to allocate more than one page.");
|
||||
buffer = valloc(NSPageSize());
|
||||
#endif /* HAVE_MMAP */
|
||||
|
||||
if (buffer == (void*)0)
|
||||
|
@ -144,7 +145,7 @@
|
|||
NSLog(@"Failed to protect memory as executable: %@", [NSError _last]);
|
||||
}
|
||||
#elif defined(HAVE_MPROTECT)
|
||||
if (mprotect(buffer,sysconf(_SC_PAGESIZE), PROT_READ|PROT_EXEC) == -1)
|
||||
if (mprotect(buffer, NSPageSize(), PROT_READ|PROT_EXEC) == -1)
|
||||
{
|
||||
NSLog(@"Failed to protect memory as executable: %@", [NSError _last]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue