1 /* Copyright (C) 1999,2000,2001,2002,2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 1999.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25 #include <sys/syscall.h>
26 #include <bp-checks.h>
28 #include <kernel-features.h>
32 /* This is always 12, even on architectures where PAGE_SHIFT != 12. */
33 # ifndef MMAP2_PAGE_SHIFT
34 # define MMAP2_PAGE_SHIFT 12
37 # ifndef __ASSUME_MMAP2_SYSCALL
38 static int have_no_mmap2
;
44 __mmap64 (void *addr
, size_t len
, int prot
, int flags
, int fd
, off64_t offset
)
47 if (offset
& ((1 << MMAP2_PAGE_SHIFT
) - 1))
52 # ifndef __ASSUME_MMAP2_SYSCALL
56 # ifndef __ASSUME_MMAP2_SYSCALL
57 int saved_errno
= errno
;
60 __ptrvalue (result
) = (void *__unbounded
)
61 INLINE_SYSCALL (mmap2
, 6, __ptrvalue (addr
),
63 (off_t
) (offset
>> MMAP2_PAGE_SHIFT
));
64 # if __BOUNDED_POINTERS__
65 __ptrlow (result
) = __ptrvalue (result
);
66 __ptrhigh (result
) = __ptrvalue (result
) + len
;
68 # ifndef __ASSUME_MMAP2_SYSCALL
69 if (result
!= MAP_FAILED
|| errno
!= ENOSYS
)
73 # ifndef __ASSUME_MMAP2_SYSCALL
74 __set_errno (saved_errno
);
79 #ifndef __ASSUME_MMAP2_SYSCALL
80 if (offset
!= (off_t
) offset
|| (offset
+ len
) != (off_t
) (offset
+ len
))
86 return __mmap (addr
, len
, prot
, flags
, fd
, (off_t
) offset
);
89 weak_alias (__mmap64
, mmap64
)