2010-03-21 Maxim Kuvyrkov * sysdeps/unix/sysv/linux/mmap64.c (page_shift): New static variable. (__map64): Initialize page_shift, if needed, and use it instead of MMAP2_PAGE_SHIFT macro. --- sysdeps/unix/sysv/linux/mmap64.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/mmap64.c b/sysdeps/unix/sysv/linux/mmap64.c index d3c68cd..eb5f187 100644 --- a/sysdeps/unix/sysv/linux/mmap64.c +++ b/sysdeps/unix/sysv/linux/mmap64.c @@ -34,6 +34,8 @@ # define MMAP2_PAGE_SHIFT 12 # endif +static int page_shift = MMAP2_PAGE_SHIFT; + # ifndef __ASSUME_MMAP2_SYSCALL static int have_no_mmap2; # endif @@ -44,7 +46,17 @@ void * __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset) { #ifdef __NR_mmap2 - if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) +# if MMAP2_PAGE_SHIFT == -1 + if (page_shift == -1) + { + int page_size; + + page_size = getpagesize (); + while ((1 << ++page_shift) != page_size); + } +# endif + + if (offset & ((1 << page_shift) - 1)) { __set_errno (EINVAL); return MAP_FAILED; @@ -60,7 +72,7 @@ __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset) __ptrvalue (result) = (void *__unbounded) INLINE_SYSCALL (mmap2, 6, __ptrvalue (addr), len, prot, flags, fd, - (off_t) (offset >> MMAP2_PAGE_SHIFT)); + (off_t) (offset >> page_shift)); # if __BOUNDED_POINTERS__ __ptrlow (result) = __ptrvalue (result); __ptrhigh (result) = __ptrvalue (result) + len; -- 1.6.6.1