1 /* Definitions for POSIX-style memory management. Linux version.
2 Copyright (C) 1994, 1995, 1996, 1997, 1998 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. */
24 #include <bits/types.h>
28 /* Get the bit values from the kernel header file. */
29 #include <bits/mman.h>
31 /* Return value of `mmap' in case of an error. */
32 #define MAP_FAILED ((__ptr_t) -1)
35 /* Map addresses starting near ADDR and extending for LEN bytes. from
36 OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
37 is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
38 set in FLAGS, the mapping will be at ADDR exactly (which must be
39 page-aligned); otherwise the system chooses a convenient nearby address.
40 The return value is the actual mapping address chosen or MAP_FAILED
41 for errors (in which case `errno' is set). A successful `mmap' call
42 deallocates any previous mapping for the affected region. */
44 #ifndef __USE_FILE_OFFSET64
45 extern __ptr_t mmap
__P ((__ptr_t __addr
, size_t __len
, int __prot
,
46 int __flags
, int __fd
, __off_t __offset
));
48 extern __ptr_t mmap
__P ((__ptr_t __addr
, size_t __len
, int __prot
,
49 int __flags
, int __fd
, __off64_t __offset
))
52 #ifdef __USE_LARGEFILE64
53 extern __ptr_t mmap64
__P ((__ptr_t __addr
, size_t __len
, int __prot
,
54 int __flags
, int __fd
, __off64_t __offset
));
57 /* Deallocate any mapping for the region starting at ADDR and extending LEN
58 bytes. Returns 0 if successful, -1 for errors (and sets errno). */
59 extern int munmap
__P ((__ptr_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
64 extern int mprotect
__P ((__ptr_t __addr
, size_t __len
, int __prot
));
66 /* Synchronize the region starting at ADDR and extending LEN bytes with the
67 file it maps. Filesystem operations on a file being mapped are
68 unpredictable before this is done. Flags are from the MS_* set. */
69 extern int msync
__P ((__ptr_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 ((__ptr_t __addr
, size_t __len
, int __advice
));
77 /* Cause all currently mapped pages of the process to be memory resident
78 until unlocked by a call to the `munlockall', until the process exits,
79 or until the process calls `execve'. */
80 extern int mlockall
__P ((int __flags
));
82 /* All currently mapped pages of the process' address space become
84 extern int munlockall
__P ((void));
86 /* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
87 be memory resident. */
88 extern int mlock
__P ((__const __ptr_t __addr
, size_t __len
));
90 /* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). */
91 extern int munlock
__P ((__const __ptr_t __addr
, size_t __len
));
94 /* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length
95 NEW_LEN. If MAY_MOVE is MREMAP_MAYMOVE the returned address may
97 extern __ptr_t mremap
__P ((__ptr_t __addr
, size_t __old_len
,
98 size_t __new_len
, int __may_move
));
103 #endif /* _SYS_MMAN_H */