diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-06-27 08:05:40 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-06-27 08:05:40 +0000 |
commit | 0849bd1b703c3edf13461badd638ef0b81fa3efe (patch) | |
tree | f5c509019dc3c60a8da9a2f8dc79da74abf1aaf7 /libc/sysdeps/linux/common/mmap64.c | |
parent | 1f6145faf0b4e1fdbd5ad7240896bec9804e7ff5 (diff) |
Actually, some arches do support _syscall6, so implement a generic version
for them...
-Erik
Diffstat (limited to 'libc/sysdeps/linux/common/mmap64.c')
-rw-r--r-- | libc/sysdeps/linux/common/mmap64.c | 43 |
1 files changed, 36 insertions, 7 deletions
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 <errno.h> #include <unistd.h> #include <sysdep.h> #include <sys/mman.h> -/* 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__ */ |