From 0849bd1b703c3edf13461badd638ef0b81fa3efe Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Fri, 27 Jun 2003 08:05:40 +0000 Subject: Actually, some arches do support _syscall6, so implement a generic version for them... -Erik --- libc/sysdeps/linux/common/mmap64.c | 43 +++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'libc') diff --git a/libc/sysdeps/linux/common/mmap64.c b/libc/sysdeps/linux/common/mmap64.c index 0a67abba2..1f1b8dc9a 100644 --- a/libc/sysdeps/linux/common/mmap64.c +++ b/libc/sysdeps/linux/common/mmap64.c @@ -17,17 +17,13 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +/* Massivly hacked up for uClibc by Erik Andersen */ + #include #include #include #include -/* Massivly hackd up for uClibc by Erik Andersen - * - * This version is a stub that just chops off everything at the mmap 32 bit - * mmap() address space... You need to add in an arch specific implementation - * to override this as there is not a generic way for me to implement this - * particular syscall. */ #if defined __UCLIBC_HAS_LFS__ @@ -44,7 +40,17 @@ # undef __USE_FILE_OFFSET64 #endif -#undef creat + +#if ! defined __NR_mmap2 || ! defined _syscall6 + +/* + * This version is a stub that just chops off everything at the mmap 32 bit + * mmap() address space... You will probably need to add in an arch specific + * implementation to override this as there is not a generic way for me to + * implement this particular syscall if your arch lacks _syscall6... + * +*/ + __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t offset) { if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len)) @@ -55,5 +61,28 @@ __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t return mmap (addr, len, prot, flags, fd, (off_t) offset); } + +#else + +#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); + +/* This is always 12, even on architectures where PAGE_SHIFT != 12. */ +# ifndef MMAP2_PAGE_SHIFT +# define MMAP2_PAGE_SHIFT 12 +# endif + +void * __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset) +{ + void *result; + if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) { + __set_errno (EINVAL); + return MAP_FAILED; + } + return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT))); +} + +#endif #endif /* __UCLIBC_HAS_LFS__ */ -- cgit v1.2.3