7 #include <sys/syscall.h>
10 #include <asm/page.h> /* For PAGE_SHIFT */
12 #if defined(__sparc__)
13 # define MMAP2_SHIFT 12 /* Fixed by syscall definition */
14 #elif defined(__mips__) || defined(__powerpc__)
15 # define MMAP2_SHIFT __getpageshift() /* Variable */
17 # define MMAP2_SHIFT PAGE_SHIFT
21 * Set in SYSCALLS whether or not we should use an unadorned mmap() system
22 * call (typical on 64-bit architectures).
24 #if (BITSIZE == 32 && defined(__NR_mmap2)) || (BITSIZE == 64 && !defined(__NR_mmap))
26 /* This architecture uses mmap2(). The Linux mmap2() system call takes
27 a page offset as the offset argument. We need to make sure we have
28 the proper conversion in place. */
30 extern void *__mmap2(void *, size_t, int, int, int, size_t);
32 void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
34 const int mmap2_shift = MMAP2_SHIFT;
35 const unsigned long mmap2_mask = (1UL << mmap2_shift) - 1;
37 if ( offset & mmap2_mask ) {
42 return __mmap2(start, length, prot, flags, fd, (size_t)offset >> mmap2_shift);