implement vm_page_size() to get the actual size of a page

This commit is contained in:
gbeauche 2004-12-11 10:19:34 +00:00
parent ce1420dcce
commit fc47096ef8
2 changed files with 16 additions and 5 deletions

View File

@ -449,6 +449,17 @@ int vm_protect(void * addr, size_t size, int prot)
#endif
}
/* Returns the size of a page. */
int vm_page_size(void)
{
#ifdef _WIN32
return 4096;
#else
return getpagesize();
#endif
}
#ifdef CONFIGURE_TEST_VM_MAP
/* Tests covered here:
- TEST_VM_PROT_* program slices actually succeeds when a crash occurs
@ -459,11 +470,7 @@ int main(void)
vm_init();
#define page_align(address) ((char *)((unsigned long)(address) & -page_size))
#ifdef _WIN32
const unsigned long page_size = 4096;
#else
unsigned long page_size = getpagesize();
#endif
unsigned long page_size = vm_page_size();
const int area_size = 6 * page_size;
volatile char * area = (volatile char *) vm_acquire(area_size);

View File

@ -109,4 +109,8 @@ extern int vm_release(void * addr, size_t size);
extern int vm_protect(void * addr, size_t size, int prot);
/* Returns the size of a page. */
extern int vm_page_size(void);
#endif /* VM_ALLOC_H */