summaryrefslogtreecommitdiff
path: root/ldso/include
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-10-15 19:15:41 -0400
committerMike Frysinger <vapier@gentoo.org>2009-10-15 19:15:41 -0400
commit2b599542471c78ec04d5542e017dbc911d690f16 (patch)
tree696b1781877b0372e979436124ee2ad47731657c /ldso/include
parentc5225dd5c9346e0f35b3918c8fe1c734054d2b1a (diff)
ldso: unify and cleanup _dl_mmap code
The interface should be straight forward now and the same for everyone. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'ldso/include')
-rw-r--r--ldso/include/dl-syscall.h62
1 files changed, 22 insertions, 40 deletions
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index 20d443edf..0be937b5e 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -135,30 +135,6 @@ static __always_inline _syscall2(int, _dl_gettimeofday, struct timeval *, tv,
# endif
#endif
-
-/* handle all the fun mmap intricacies */
-#define MAP_FAILED ((void *) -1)
-#if (defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)) || !defined(__NR_mmap2)
-# define _dl_MAX_ERRNO 4096
-# define _dl_mmap_check_error(__res) \
- (((long)__res) < 0 && ((long)__res) >= -_dl_MAX_ERRNO)
-#else
-# define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED)
-#endif
-
-/* first try mmap(), syscall6() style */
-#if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
-
-# define __NR__dl_mmap __NR_mmap
-static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
- int, prot, int, flags, int, fd, off_t, offset);
-/* then try mmap2() */
-#elif defined(__NR_mmap2) && !defined (__mcoldfire__)
-
-# define __NR___syscall_mmap2 __NR_mmap2
-static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
- int, prot, int, flags, int, fd, off_t, offset);
-
/* 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...
@@ -167,35 +143,41 @@ static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t
# 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)
+#define MAP_FAILED ((void *) -1)
+#define _dl_mmap_check_error(X) (((void *)X) == MAP_FAILED)
+
+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;
- return __syscall_mmap2(addr, size, prot, flags,
- fd, (off_t) (offset >> MMAP2_PAGE_SHIFT));
-}
-/* finally, fall back to mmap(), syscall1() style */
-#elif defined(__NR_mmap)
-# define __NR__dl_mmap_real __NR_mmap
-static __always_inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
-static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
- int flags, int fd, unsigned long offset)
-{
- unsigned long buffer[6];
+ /* 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 *) _dl_mmap_real(buffer);
-}
-
+ return (void *)INLINE_SYSCALL(mmap, 1, buffer);
#else
# error "Your architecture doesn't seem to provide mmap() !?"
#endif
+}
#endif /* _LD_SYSCALL_H_ */