From: Ulrich Drepper Date: Fri, 20 Apr 2001 04:53:42 +0000 (+0000) Subject: (__mmap64): Optimize a bit. X-Git-Tag: upstream/2.30~23190 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=821fcfd5c3c0f3799b37fded7321199cdceade7e;p=external%2Fglibc.git (__mmap64): Optimize a bit. --- diff --git a/sysdeps/unix/sysv/linux/powerpc/mmap64.c b/sysdeps/unix/sysv/linux/powerpc/mmap64.c index fc0c959..4b3e60d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/mmap64.c +++ b/sysdeps/unix/sysv/linux/powerpc/mmap64.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 1999. @@ -39,28 +39,32 @@ static int have_no_mmap2; #endif #endif -__ptr_t -__mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd, off64_t offset) +void * +__mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset) { + if (! (offset & ((1 << PAGE_SHIFT)-1))) + { + __set_errno (EINVAL); + return MAP_FAILED; + } #ifdef __NR_mmap2 - if ( # ifndef __ASSUME_MMAP2_SYSCALL - ! have_no_mmap2 && + if (! have_no_mmap2) # endif - ! (offset & ((1 << PAGE_SHIFT)-1))) { # ifndef __ASSUME_MMAP2_SYSCALL int saved_errno = errno; # endif - __ptr_t result; - __ptrvalue (result) = INLINE_SYSCALL (mmap2, 6, __ptrvalue (addr), len, prot, - flags, fd, (off_t) (offset >> PAGE_SHIFT)); + void *result; + __ptrvalue (result) = INLINE_SYSCALL (mmap2, 6, __ptrvalue (addr), len, + prot, flags, fd, + (off_t) (offset >> PAGE_SHIFT)); # if __BOUNDED_POINTERS__ __ptrlow (result) = __ptrvalue (result); __ptrhigh (result) = __ptrvalue (result) + len; # endif # ifndef __ASSUME_MMAP2_SYSCALL - if (result != (__ptr_t) -1 || errno != ENOSYS) + if (result != MAP_FAILED || errno != ENOSYS) # endif return result; @@ -70,6 +74,7 @@ __mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd, off64_t offset) # endif } #endif +#ifndef __ASSUME_MMAP2_SYSCALL if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len)) { __set_errno (EINVAL); @@ -77,6 +82,7 @@ __mmap64 (__ptr_t addr, size_t len, int prot, int flags, int fd, off64_t offset) } return __mmap (addr, len, prot, flags, fd, (off_t) offset); +#endif } weak_alias (__mmap64, mmap64)