~ubuntu-branches/ubuntu/trusty/eglibc/trusty

« back to all changes in this revision

Viewing changes to sysdeps/unix/sysv/linux/mmap64.c

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2013-01-10 18:39:35 UTC
  • mfrom: (1.5.2) (4.4.24 experimental)
  • Revision ID: package-import@ubuntu.com-20130110183935-afsgfxkmg7wk5eaj
Tags: 2.17-0ubuntu1
* Merge with Debian, bringing in a new upstream and many small fixes:
  - patches/any/cvs-malloc-deadlock.diff: Dropped, merged upstream.
  - patches/ubuntu/lddebug-scopes.diff: Rebase for upstream changes.
  - patches/ubuntu/local-CVE-2012-3406.diff: Rebased against upstream.
  - patches/ubuntu/no-asm-mtune-i686.diff: Fixed in recent binutils.
* This upstream merge fixes a nasty hang in pulseaudio (LP: #1085342)
* Bump MIN_KERNEL_SUPPORTED to 2.6.32 on ARM, now that we no longer
  have to support shonky 2.6.31 kernels on imx51 babbage builders.
* Drop patches/ubuntu/local-disable-nscd-host-caching.diff, as these
  issues were apparently resolved upstream a while ago (LP: #613662)
* Fix the compiled-in bug URL to point to launchpad.net, not Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
4
4
 
26
26
 
27
27
#include <kernel-features.h>
28
28
 
29
 
#ifdef __NR_mmap2
30
 
 
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;
34
 
# else
35
 
#  ifndef MMAP2_PAGE_SHIFT
36
 
#   define MMAP2_PAGE_SHIFT 12
37
 
#  endif
38
 
# define page_shift MMAP2_PAGE_SHIFT
39
 
# endif
40
 
 
41
 
# ifndef __ASSUME_MMAP2_SYSCALL
42
 
static int have_no_mmap2;
43
 
# endif
 
32
#else
 
33
# ifndef MMAP2_PAGE_SHIFT
 
34
#  define MMAP2_PAGE_SHIFT 12
 
35
# endif
 
36
#define page_shift MMAP2_PAGE_SHIFT
44
37
#endif
45
38
 
46
39
 
47
40
void *
48
41
__mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset)
49
42
{
50
 
#ifdef __NR_mmap2
51
 
# if MMAP2_PAGE_SHIFT == -1
 
43
#if MMAP2_PAGE_SHIFT == -1
52
44
  if (page_shift == 0)
53
45
    {
54
46
      int page_size = getpagesize ();
55
47
      while ((1 << ++page_shift) != page_size)
56
48
        ;
57
49
    }
58
 
# endif
 
50
#endif
59
51
  if (offset & ((1 << page_shift) - 1))
60
52
    {
61
53
      __set_errno (EINVAL);
62
54
      return MAP_FAILED;
63
55
    }
64
 
# ifndef __ASSUME_MMAP2_SYSCALL
65
 
  if (! have_no_mmap2)
66
 
# endif
67
 
    {
68
 
# ifndef __ASSUME_MMAP2_SYSCALL
69
 
      int saved_errno = errno;
70
 
# endif
71
 
      void *result;
72
 
      __ptrvalue (result) = (void *__unbounded)
73
 
        INLINE_SYSCALL (mmap2, 6, __ptrvalue (addr),
74
 
                        len, prot, flags, fd,
75
 
                        (off_t) (offset >> MMAP2_PAGE_SHIFT));
76
 
# if __BOUNDED_POINTERS__
77
 
      __ptrlow (result) = __ptrvalue (result);
78
 
      __ptrhigh (result) = __ptrvalue (result) + len;
79
 
# endif
80
 
# ifndef __ASSUME_MMAP2_SYSCALL
81
 
      if (result != MAP_FAILED || errno != ENOSYS)
82
 
# endif
83
 
        return result;
84
 
 
85
 
# ifndef __ASSUME_MMAP2_SYSCALL
86
 
      __set_errno (saved_errno);
87
 
      have_no_mmap2 = 1;
88
 
# endif
89
 
    }
90
 
#endif
91
 
#ifndef __ASSUME_MMAP2_SYSCALL
92
 
  if (offset != (off_t) offset || (offset + len) != (off_t) (offset + len))
93
 
    {
94
 
      __set_errno (EINVAL);
95
 
      return MAP_FAILED;
96
 
    }
97
 
 
98
 
  return __mmap (addr, len, prot, flags, fd, (off_t) offset);
99
 
#endif
 
56
  void *result;
 
57
  __ptrvalue (result) = (void *__unbounded)
 
58
    INLINE_SYSCALL (mmap2, 6, __ptrvalue (addr),
 
59
                    len, prot, flags, fd,
 
60
                    (off_t) (offset >> MMAP2_PAGE_SHIFT));
 
61
#if __BOUNDED_POINTERS__
 
62
  __ptrlow (result) = __ptrvalue (result);
 
63
  __ptrhigh (result) = __ptrvalue (result) + len;
 
64
#endif
 
65
  return result;
100
66
}
101
67
weak_alias (__mmap64, mmap64)