Update.
[glibc.git] / sysdeps / unix / sysv / linux / sys / mman.h
blob129702e33c7cb7ae9d0a1547d45095374133c52f
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 /* Get the bit values from the kernel header file. */
30 #include <bits/mman.h>
32 /* Return value of `mmap' in case of an error. */
33 #define MAP_FAILED ((__caddr_t) -1)
35 __BEGIN_DECLS
36 /* Map addresses starting near ADDR and extending for LEN bytes. from
37 OFFSET into the file FD describes according to PROT and FLAGS. If ADDR
38 is nonzero, it is the desired mapping address. If the MAP_FIXED bit is
39 set in FLAGS, the mapping will be at ADDR exactly (which must be
40 page-aligned); otherwise the system chooses a convenient nearby address.
41 The return value is the actual mapping address chosen or MAP_FAILED
42 for errors (in which case `errno' is set). A successful `mmap' call
43 deallocates any previous mapping for the affected region. */
45 extern __caddr_t __mmap __P ((__caddr_t __addr, size_t __len, int __prot,
46 int __flags, int __fd, __off_t __offset));
47 #ifndef __USE_FILE_OFFSET64
48 extern __caddr_t mmap __P ((__caddr_t __addr, size_t __len, int __prot,
49 int __flags, int __fd, __off_t __offset));
50 #else
51 extern __caddr_t mmap __P ((__caddr_t __addr, size_t __len, int __prot,
52 int __flags, int __fd, __off_t __offset))
53 __asm__ ("mmap64");
54 #endif
55 #ifdef __USE_LARGEFILE64
56 extern __caddr_t mmap64 __P ((__caddr_t __addr, size_t __len, int __prot,
57 int __flags, int __fd, __off64_t __offset));
58 #endif
60 /* Deallocate any mapping for the region starting at ADDR and extending LEN
61 bytes. Returns 0 if successful, -1 for errors (and sets errno). */
62 extern int __munmap __P ((__caddr_t __addr, size_t __len));
63 extern int munmap __P ((__caddr_t __addr, size_t __len));
65 /* Change the memory protection of the region starting at ADDR and
66 extending LEN bytes to PROT. Returns 0 if successful, -1 for errors
67 (and sets errno). */
68 extern int __mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
69 extern int mprotect __P ((__caddr_t __addr, size_t __len, int __prot));
71 /* Synchronize the region starting at ADDR and extending LEN bytes with the
72 file it maps. Filesystem operations on a file being mapped are
73 unpredictable before this is done. Flags are from the MS_* set. */
74 extern int msync __P ((__caddr_t __addr, size_t __len, int __flags));
76 #ifdef __USE_BSD
77 /* Advise the system about particular usage patterns the program follows
78 for the region starting at ADDR and extending LEN bytes. */
79 extern int madvise __P ((__caddr_t __addr, size_t __len, int __advice));
80 #endif
82 /* Cause all currently mapped pages of the process to be memory resident
83 until unlocked by a call to the `munlockall', until the process exits,
84 or until the process calls `execve'. */
85 extern int mlockall __P ((int __flags));
87 /* All currently mapped pages of the process' address space become
88 unlocked. */
89 extern int munlockall __P ((void));
91 /* Guarantee all whole pages mapped by the range [ADDR,ADDR+LEN) to
92 be memory resident. */
93 extern int mlock __P ((__caddr_t __addr, size_t __len));
95 /* Unlock whole pages previously mapped by the range [ADDR,ADDR+LEN). */
96 extern int munlock __P ((__caddr_t __addr, size_t __len));
98 #ifdef __USE_MISC
99 /* Remap pages mapped by the range [ADDR,ADDR+OLD_LEN) to new length
100 NEW_LEN. If MAY_MOVE is MREMAP_MAYMOVE the returned address may
101 differ from ADDR. */
102 extern __caddr_t __mremap __P ((__caddr_t __addr, size_t __old_len,
103 size_t __new_len, int __may_move));
104 extern __caddr_t mremap __P ((__caddr_t __addr, size_t __old_len,
105 size_t __new_len, int __may_move));
106 #endif
108 __END_DECLS
111 #endif /* _SYS_MMAN_H */