Update.
[glibc.git] / sysdeps / unix / sysv / linux / sys / mman.h
blobdc9f8f7e48ac6e7c7be0e7a9dd1171e8d99c9309
1 /* Definitions for POSIX-style memory management. Linux version.
2 Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #ifndef _SYS_MMAN_H
22 #define _SYS_MMAN_H 1
23 #include <features.h>
25 #include <bits/types.h>
26 #define __need_size_t
27 #include <stddef.h>
29 #include <sys/cdefs.h>
31 /* Get the bit values from the kernel header file. */
32 #include <linux/mman.h>
34 #ifndef MAP_ANON
35 #define MAP_ANON MAP_ANONYMOUS
36 #endif
37 #ifndef MAP_FILE
38 #define MAP_FILE 0
39 #endif
41 __BEGIN_DECLS
42 /* Map addresses starting near ADDR and extending for LEN bytes. from
43 OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
44 is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
45 set in FLAGS, the mapping will be at ADDR exactly (which must be
46 page-aligned); otherwise the system chooses a convenient nearby address.
47 The return value is the actual mapping address chosen or (caddr_t) -1
48 for errors (in which case `errno' is set). A successful `mmap' call
49 deallocates any previous mapping for the affected region. */
51 extern __caddr_t __mmap __P ((__caddr_t __addr, size_t __len, int __prot,
52 int __flags, int __fd, __off_t __offset));
53 extern __caddr_t mmap __P ((__caddr_t __addr, size_t __len, int __prot,
54 int __flags, int __fd, __off_t __offset));
56 /* Deallocate any mapping for the region starting at ADDR and extending LEN
57 bytes. Returns 0 if successful, -1 for errors (and sets errno). */
58 extern int __munmap __P ((__caddr_t __addr, size_t __len));
59 extern int munmap __P ((__caddr_t __addr, size_t __len));
61 /* Change the memory protection of the region starting at ADDR and
62 extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
63 (and sets errno). */
64 extern int __mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
65 extern int mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
67 /* Synchronize the region starting at ADDR and extending LEN bytes with the
68 file it maps. Filesystem operations on a file being mapped are
69 unpredictable before this is done. Flags are from the MS_* set. */
70 extern int msync __P ((__caddr_t __addr, size_t __len, int __flags));
72 /* Advise the system about particular usage patterns the program follows
73 for the region starting at ADDR and extending LEN bytes. */
74 extern int madvise __P ((__caddr_t __addr, size_t __len, int __advice));
76 /* Cause all currently mapped pages of the process to be memory resident
77 until unlocked by a call to the `munlockall', until the process exits,
78 or until the process calls `execve'. */
79 extern int mlockall __P ((int __flags));
81 /* All currently mapped pages of the process' address space become
82 unlocked. */
83 extern int munlockall __P ((void));
85 /* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
86 be memory resident. */
87 extern int mlock __P ((__caddr_t __addr, size_t __len));
89 /* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). */
90 extern int munlock __P ((__caddr_t __addr, size_t __len));
92 /* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length
93 NEW_LEN. If MAY_MOVE is MREMAP_MAYMOVE the returned address may
94 differ from ADDR. */
95 extern __caddr_t __mremap __P ((__caddr_t __addr, size_t __old_len,
96 size_t __new_len, int __may_move));
97 extern __caddr_t mremap __P ((__caddr_t __addr, size_t __old_len,
98 size_t __new_len, int __may_move));
100 __END_DECLS
103 #endif /* _SYS_MMAN_H */