From 67334b918fc13ba3ba0ffd1e9f42797a1124ee0c Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Tue, 15 Jun 2010 05:43:38 +0000 Subject: [PATCH] minor portability improvement git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30726 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSInvocation.m | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d339b7c71..38aa12fa8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-06-15 Richard Frith-Macdonald + + * Source/NSInvocation: For portability, use NSPageSize() to find + size for page alignment. + 2010-06-15 Riccardo Mottola * Source/NSInvocation: diff --git a/Source/NSInvocation.m b/Source/NSInvocation.m index 17d63eb52..316db63fd 100644 --- a/Source/NSInvocation.m +++ b/Source/NSInvocation.m @@ -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]); }