From fc47096ef89946db5c9d31419b54a519618d7249 Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Sat, 11 Dec 2004 10:19:34 +0000 Subject: [PATCH] implement vm_page_size() to get the actual size of a page --- BasiliskII/src/Unix/vm_alloc.cpp | 17 ++++++++++++----- BasiliskII/src/Unix/vm_alloc.h | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/BasiliskII/src/Unix/vm_alloc.cpp b/BasiliskII/src/Unix/vm_alloc.cpp index 0ec44943..f96c85d4 100644 --- a/BasiliskII/src/Unix/vm_alloc.cpp +++ b/BasiliskII/src/Unix/vm_alloc.cpp @@ -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); diff --git a/BasiliskII/src/Unix/vm_alloc.h b/BasiliskII/src/Unix/vm_alloc.h index 41a7a5ed..0d7a9bd1 100644 --- a/BasiliskII/src/Unix/vm_alloc.h +++ b/BasiliskII/src/Unix/vm_alloc.h @@ -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 */