summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/mach/hurd/mmap.c15
-rw-r--r--sysdeps/unix/sysv/linux/sys/mman.h47
2 files changed, 18 insertions, 44 deletions
diff --git a/sysdeps/mach/hurd/mmap.c b/sysdeps/mach/hurd/mmap.c
index 4f9304f4f5..0ef847f7c2 100644
--- a/sysdeps/mach/hurd/mmap.c
+++ b/sysdeps/mach/hurd/mmap.c
@@ -110,6 +110,21 @@ __mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
(flags & MAP_INHERIT) == 0 ? VM_INHERIT_NONE :
(flags & (MAP_COPY|MAP_PRIVATE)) ? VM_INHERIT_COPY :
VM_INHERIT_SHARE);
+ 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_map (__mach_task_self (),
+ &mapaddr, (vm_size_t) len, (vm_address_t) 0,
+ 0, memobj, (vm_offset_t) offset,
+ flags & (MAP_COPY|MAP_PRIVATE),
+ vmprot, VM_PROT_ALL,
+ (flags & MAP_INHERIT) == 0 ? VM_INHERIT_NONE :
+ (flags & (MAP_COPY|MAP_PRIVATE)) ? VM_INHERIT_COPY :
+ VM_INHERIT_SHARE);
+ }
if (memobj != MACH_PORT_NULL)
__mach_port_deallocate (__mach_task_self (), memobj);
diff --git a/sysdeps/unix/sysv/linux/sys/mman.h b/sysdeps/unix/sysv/linux/sys/mman.h
index 9f0ef72100..ac5940b663 100644
--- a/sysdeps/unix/sysv/linux/sys/mman.h
+++ b/sysdeps/unix/sysv/linux/sys/mman.h
@@ -26,52 +26,11 @@ Cambridge, MA 02139, USA. */
#define __need_size_t
#include <stddef.h>
-
-/* Protections are chosen from these bits, OR'd together. The
- implementation does not necessarily support PROT_EXEC or PROT_WRITE
- without PROT_READ. The only guarantees are that no writing will be
- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
-
-#define PROT_NONE 0x00 /* No access. */
-#define PROT_READ 0x01 /* Pages can be read. */
-#define PROT_WRITE 0x02 /* Pages can be written. */
-#define PROT_EXEC 0x04 /* Pages can be executed. */
-
-
-/* Flags contain mapping type, sharing type and options. */
-
-/* Mapping type (must choose one and only one of these). */
-#define MAP_FILE 0x0000 /* Mapped from a file or device. */
-#define MAP_ANON 0x0020 /* Allocated from anonymous virtual memory. */
-#define MAP_TYPE 0x000f /* Mask for type field. */
-
-/* Sharing types (must choose one and only one of these). */
-#define MAP_COPY MAP_PRIVATE /* Virtual copy of region at mapping time. */
-#define MAP_SHARED 0x0001 /* Share changes. */
-#define MAP_PRIVATE 0x0002 /* Changes private; copy pages on write. */
-
-/* Other flags. */
-#define MAP_FIXED 0x0010 /* Map address must be exactly as requested. */
-#define MAP_NOEXTEND 0x0000 /* For MAP_FILE, don't change file size.
- Not available on Linux??? */
-#define MAP_HASSEMPHORE 0x0000 /* Region may contain semaphores.
- Not available on Linux??? */
-#define MAP_INHERIT 0x0000 /* Region is retained after exec.
- Not available on Linux??? */
-
-/* Advice to `madvise'. */
-#define MADV_NORMAL 0 /* No further special treatment. */
-#define MADV_RANDOM 1 /* Expect random page references. */
-#define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
-#define MADV_WILLNEED 3 /* Will need these pages. */
-#define MADV_DONTNEED 4 /* Don't need these pages. */
-
-/* Flags to `mlockall'. */
-#define MCL_CURRENT 1 /* Lock all current mappings. */
-#define MCL_FUTURE 2 /* Lock all future mappings. */
-
#include <sys/cdefs.h>
+/* Get the bit values from the kernel header file. */
+#include <linux/mman.h>
+
__BEGIN_DECLS
/* Map addresses starting near ADDR and extending for LEN bytes. from
OFFSET into the file FD describes according to PROT and FLAGS. If ADDR