2 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
4 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
6 /* Massivly hacked up for uClibc by Erik Andersen */
10 #include <sys/syscall.h>
17 * This version is a stub that just chops off everything at the mmap 32 bit
18 * mmap() address space... You will probably need to add in an arch specific
19 * implementation to override this as there is not a generic way for me to
20 * implement this particular syscall if your arch lacks _syscall6...
24 void *mmap64(void *addr, size_t len, int prot, int flags, int fd, __off64_t offset)
26 if (offset != (off_t) offset ||
27 (offset + len) != (off_t) (offset + len)) {
32 return mmap(addr, len, prot, flags, fd, (off_t) offset);
36 # include <bits/uClibc_page.h>
38 /* Some architectures always use 12 as page shift for mmap2() even though the
39 * real PAGE_SHIFT != 12. Other architectures use the same value as
42 # ifndef MMAP2_PAGE_SHIFT
43 # define MMAP2_PAGE_SHIFT 12
46 void *mmap64(void *addr, size_t len, int prot, int flags, int fd, __off64_t offset)
49 * Some arches check the size in INLINE_SYSCALL() and barf if it's
50 * too big (i.e. a 64bit value getting truncated to 32bit).
58 if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
64 * We know __off64_t is always a signed 64-bit type, but need things
65 * to be unsigned before doing the shift. If it isn't, we might
66 * sign extend things and pass in the wrong value. So cast it to
67 * an unsigned 64-bit value before doing the shift.
69 sysoff = (uint64_t)offset >> MMAP2_PAGE_SHIFT;
71 return (void*) INLINE_SYSCALL(mmap2, 6, addr, len, prot, flags, fd, sysoff);