diff options
author | Roland McGrath <roland@gnu.org> | 1999-07-11 11:44:31 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1999-07-11 11:44:31 +0000 |
commit | 57a491d1055bec7c49bd5c0149170b576b38fd7b (patch) | |
tree | 745af60a433b5585c65ae1764c3df9e17fb487fa /sysdeps/mach | |
parent | 5ef2d37b330420c89cd476afa83ca5a839094796 (diff) | |
download | glibc-57a491d1055bec7c49bd5c0149170b576b38fd7b.tar glibc-57a491d1055bec7c49bd5c0149170b576b38fd7b.tar.gz glibc-57a491d1055bec7c49bd5c0149170b576b38fd7b.tar.bz2 glibc-57a491d1055bec7c49bd5c0149170b576b38fd7b.zip |
1999-07-11 Roland McGrath <roland@baalperazim.frob.com>
* sysdeps/mach/hurd/mmap.c (__mmap): Short-circuit to vm_allocate
for MAP_ANON, prot==PROT_READ|PROT_WRITE.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r-- | sysdeps/mach/hurd/mmap.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/mmap.c b/sysdeps/mach/hurd/mmap.c index 8b4c3455c1..403678af9c 100644 --- a/sysdeps/mach/hurd/mmap.c +++ b/sysdeps/mach/hurd/mmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +/* Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -40,10 +40,29 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset) vm_address_t mapaddr; vm_size_t pageoff; + mapaddr = (vm_address_t) addr; + + if ((flags & (MAP_TYPE|MAP_INHERIT)) == MAP_ANON + && prot == (PROT_READ|PROT_WRITE)) /* cf VM_PROT_DEFAULT */ + { + /* vm_allocate has (a little) less overhead in the kernel too. */ + err = __vm_allocate (&mapaddr, len, !(flags & MAP_FIXED)); + + if (err == KERN_NO_SPACE && (flags & MAP_FIXED)) + { + /* XXX this is not atomic as it is in unix! */ + /* The region is already allocated; deallocate it first. */ + err = __vm_deallocate (__mach_task_self (), mapaddr, len); + if (!err) + err = __vm_allocate (&mapaddr, len, 0); + } + + return err ? (__ptr_t) (long int) __hurd_fail (err) : (__ptr_t) mapaddr; + } + pageoff = offset & (vm_page_size - 1); offset &= ~(vm_page_size - 1); - mapaddr = (vm_address_t) addr; if (flags & MAP_FIXED) { /* A specific address is requested. It need not be page-aligned; |