1
/* Copyright (C) 1999,2000,2001,2002,2006,2010 Free Software Foundation, Inc.
1
/* Copyright (C) 1999-2012 Free Software Foundation, Inc.
2
2
This file is part of the GNU C Library.
3
3
Contributed by Jakub Jelinek <jakub@redhat.com>, 1999.
27
27
#include <kernel-features.h>
31
29
/* This is always 12, even on architectures where PAGE_SHIFT != 12. */
32
# if MMAP2_PAGE_SHIFT == -1
30
#if MMAP2_PAGE_SHIFT == -1
33
31
static int page_shift;
35
# ifndef MMAP2_PAGE_SHIFT
36
# define MMAP2_PAGE_SHIFT 12
38
# define page_shift MMAP2_PAGE_SHIFT
41
# ifndef __ASSUME_MMAP2_SYSCALL
42
static int have_no_mmap2;
33
# ifndef MMAP2_PAGE_SHIFT
34
# define MMAP2_PAGE_SHIFT 12
36
#define page_shift MMAP2_PAGE_SHIFT
48
41
__mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
51
# if MMAP2_PAGE_SHIFT == -1
43
#if MMAP2_PAGE_SHIFT == -1
52
44
if (page_shift == 0)
54
46
int page_size = getpagesize ();
55
47
while ((1 << ++page_shift) != page_size)
59
51
if (offset & ((1 << page_shift) - 1))
61
53
__set_errno (EINVAL);
64
# ifndef __ASSUME_MMAP2_SYSCALL
68
# ifndef __ASSUME_MMAP2_SYSCALL
69
int saved_errno = errno;
72
__ptrvalue (result) = (void *__unbounded)
73
INLINE_SYSCALL (mmap2, 6, __ptrvalue (addr),
75
(off_t) (offset >> MMAP2_PAGE_SHIFT));
76
# if __BOUNDED_POINTERS__
77
__ptrlow (result) = __ptrvalue (result);
78
__ptrhigh (result) = __ptrvalue (result) + len;
80
# ifndef __ASSUME_MMAP2_SYSCALL
81
if (result != MAP_FAILED || errno != ENOSYS)
85
# ifndef __ASSUME_MMAP2_SYSCALL
86
__set_errno (saved_errno);
91
#ifndef __ASSUME_MMAP2_SYSCALL
92
if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len))
98
return __mmap (addr, len, prot, flags, fd, (off_t) offset);
57
__ptrvalue (result) = (void *__unbounded)
58
INLINE_SYSCALL (mmap2, 6, __ptrvalue (addr),
60
(off_t) (offset >> MMAP2_PAGE_SHIFT));
61
#if __BOUNDED_POINTERS__
62
__ptrlow (result) = __ptrvalue (result);
63
__ptrhigh (result) = __ptrvalue (result) + len;
101
67
weak_alias (__mmap64, mmap64)