[git commit ldso-future] dl-syscall.h: remove inconsistent mmap implementation, use the common one
Peter S. Mazinger
ps.m at gmx.net
Mon Apr 11 11:27:03 UTC 2011
commit: http://git.uclibc.org/uClibc/commit/?id=820bfb1fae5fb1d66f2bf5f8b989bac7bf3e4a93
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/ldso-future
Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
ldso/include/dl-syscall.h | 42 +-------------------------------------
libc/sysdeps/linux/common/mmap.c | 26 +++++++++++++----------
2 files changed, 16 insertions(+), 52 deletions(-)
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index 2cf58ff..0b1c6c2 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -115,47 +115,7 @@ static __always_inline _syscall2(int, _dl_gettimeofday, struct timeval *, tv,
__timezone_ptr_t, tz)
#endif
-/* Some architectures always use 12 as page shift for mmap2() eventhough the
- * real PAGE_SHIFT != 12. Other architectures use the same value as
- * PAGE_SHIFT...
- */
-#ifndef MMAP2_PAGE_SHIFT
-# define MMAP2_PAGE_SHIFT 12
-#endif
-
-static __always_inline
-void *_dl_mmap(void *addr, unsigned long size, int prot,
- int flags, int fd, unsigned long offset)
-{
-#if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
- /* first try mmap(), syscall6() style */
- return (void *)INLINE_SYSCALL(mmap, 6, addr, size, prot, flags, fd, offset);
-
-#elif defined(__NR_mmap2) && !defined (__mcoldfire__)
- /* then try mmap2() */
- unsigned long shifted;
-
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
- return MAP_FAILED;
-
- /* gcc needs help with putting things onto the stack */
- shifted = offset >> MMAP2_PAGE_SHIFT;
- return (void *)INLINE_SYSCALL(mmap2, 6, addr, size, prot, flags, fd, shifted);
-
-#elif defined(__NR_mmap)
- /* finally, fall back to mmap(), syscall1() style */
- unsigned long buffer[6];
- buffer[0] = (unsigned long) addr;
- buffer[1] = (unsigned long) size;
- buffer[2] = (unsigned long) prot;
- buffer[3] = (unsigned long) flags;
- buffer[4] = (unsigned long) fd;
- buffer[5] = (unsigned long) offset;
- return (void *)INLINE_SYSCALL(mmap, 1, buffer);
-#else
-# error "Your architecture doesn't seem to provide mmap() !?"
-#endif
-}
+#include "../../libc/sysdeps/linux/common/mmap.c"
#else /* IS_IN_rtld */
diff --git a/libc/sysdeps/linux/common/mmap.c b/libc/sysdeps/linux/common/mmap.c
index dbc66c2..4446a02 100644
--- a/libc/sysdeps/linux/common/mmap.c
+++ b/libc/sysdeps/linux/common/mmap.c
@@ -16,9 +16,9 @@
# error disable __UCLIBC_MMAP_HAS_6_ARGS__ for this arch
# endif
-# define __NR__mmap __NR_mmap
-static _syscall6(void *, _mmap, void *, addr, size_t, len,
- int, prot, int, flags, int, fd, __off_t, offset)
+# define __NR__dl_mmap __NR_mmap
+static __always_inline _syscall6(void *, _dl_mmap, void *, addr, size_t, len,
+ int, prot, int, flags, int, fd, __off_t, offset)
#elif defined __NR_mmap2 && defined _syscall6
@@ -29,17 +29,19 @@ static _syscall6(void *, _mmap, void *, addr, size_t, len,
# endif
# define __NR___syscall_mmap2 __NR_mmap2
-static __inline__ _syscall6(void *, __syscall_mmap2, void *, addr, size_t, len,
- int, prot, int, flags, int, fd, __off_t, offset)
+static __always_inline _syscall6(void *, __syscall_mmap2, void *, addr, size_t, len,
+ int, prot, int, flags, int, fd, __off_t, offset)
-static void *_mmap(void *addr, size_t len, int prot, int flags,
- int fd, __off_t offset)
+static __always_inline void *_dl_mmap(void *addr, size_t len, int prot, int flags,
+ int fd, __off_t offset)
{
const int mmap2_shift = MMAP2_PAGE_SHIFT;
const __off_t mmap2_mask = ((__off_t) 1 << MMAP2_PAGE_SHIFT) - 1;
/* check if offset is page aligned */
if (offset & mmap2_mask) {
+# ifndef IS_IN_rtld
__set_errno(EINVAL);
+# endif
return MAP_FAILED;
}
# ifdef __USE_FILE_OFFSET64
@@ -54,10 +56,10 @@ static void *_mmap(void *addr, size_t len, int prot, int flags,
#elif defined __NR_mmap
# define __NR___syscall_mmap __NR_mmap
-static __inline__ _syscall1(void *, __syscall_mmap, unsigned long *, buffer)
+static __always_inline _syscall1(void *, __syscall_mmap, unsigned long *, buffer)
-static void *_mmap(void *addr, size_t len, int prot, int flags,
- int fd, __off_t offset)
+static __always_inline void *_dl_mmap(void *addr, size_t len, int prot, int flags,
+ int fd, __off_t offset)
{
unsigned long buffer[6];
@@ -76,5 +78,7 @@ static void *_mmap(void *addr, size_t len, int prot, int flags,
#endif
-strong_alias(_mmap,mmap)
+#ifndef IS_IN_rtld
+strong_alias(_dl_mmap,mmap)
+#endif
libc_hidden_def(mmap)
--
1.7.3.4
More information about the uClibc-cvs
mailing list