resolved conflicts for merge of e35d6c28 to master

Change-Id: I237bfc35d872a2e2ff10984012f9811488a5cea7
This commit is contained in:
Elliott Hughes 2013-07-17 13:28:30 -07:00
commit 4add6968be
2 changed files with 19 additions and 16 deletions

View File

@ -106,7 +106,6 @@ libc_common_src_files := \
bionic/md5.c \ bionic/md5.c \
bionic/memmem.c \ bionic/memmem.c \
bionic/memswap.c \ bionic/memswap.c \
bionic/mmap.c \
bionic/openat.c \ bionic/openat.c \
bionic/open.c \ bionic/open.c \
bionic/pathconf.c \ bionic/pathconf.c \
@ -200,6 +199,7 @@ libc_bionic_src_files := \
bionic/__memcpy_chk.cpp \ bionic/__memcpy_chk.cpp \
bionic/__memmove_chk.cpp \ bionic/__memmove_chk.cpp \
bionic/__memset_chk.cpp \ bionic/__memset_chk.cpp \
bionic/mmap.cpp \
bionic/pthread_attr.cpp \ bionic/pthread_attr.cpp \
bionic/pthread_detach.cpp \ bionic/pthread_detach.cpp \
bionic/pthread_equal.cpp \ bionic/pthread_equal.cpp \

View File

@ -25,27 +25,30 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <unistd.h>
#include <errno.h> #include <errno.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <unistd.h>
extern void* __mmap2(void*, size_t, int, int, int, size_t); #include "private/ErrnoRestorer.h"
#define MMAP2_SHIFT 12 // mmap2(2) is like mmap(2), but the offset is in 4096-byte blocks, not bytes.
void* mmap(void *addr, size_t size, int prot, int flags, int fd, long offset) extern "C" void* __mmap2(void*, size_t, int, int, int, size_t);
{
void *ret;
if (offset & ((1UL << MMAP2_SHIFT)-1)) { #define MMAP2_SHIFT 12 // 2**12 == 4096
errno = EINVAL;
return MAP_FAILED;
}
ret = __mmap2(addr, size, prot, flags, fd, (size_t)offset >> MMAP2_SHIFT); void* mmap(void* addr, size_t size, int prot, int flags, int fd, long offset) {
if (offset & ((1UL << MMAP2_SHIFT)-1)) {
errno = EINVAL;
return MAP_FAILED;
}
if ((ret != MAP_FAILED) && (flags & (MAP_PRIVATE | MAP_ANONYMOUS))) { void* result = __mmap2(addr, size, prot, flags, fd, offset >> MMAP2_SHIFT);
madvise(ret, size, MADV_MERGEABLE);
}
return ret; if (result != MAP_FAILED && (flags & (MAP_PRIVATE | MAP_ANONYMOUS)) != 0) {
ErrnoRestorer errno_restorer;
madvise(result, size, MADV_MERGEABLE);
}
return result;
} }