Back to index

glibc  2.9
mman.h
Go to the documentation of this file.
00001 /* Definitions for BSD-style memory management.
00002    Copyright (C) 1994-1998,2000,01,02,05 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 /* These are the bits used by 4.4 BSD and its derivatives.  On systems
00021    (such as GNU) where these facilities are not system services but can be
00022    emulated in the C library, these are the definitions we emulate.  */
00023 
00024 #ifndef _SYS_MMAN_H
00025 # error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
00026 #endif
00027 
00028 /* Protections are chosen from these bits, OR'd together.  The
00029    implementation does not necessarily support PROT_EXEC or PROT_WRITE
00030    without PROT_READ.  The only guarantees are that no writing will be
00031    allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
00032 
00033 #define       PROT_NONE      0x00  /* No access.  */
00034 #define       PROT_READ      0x04  /* Pages can be read.  */
00035 #define       PROT_WRITE     0x02  /* Pages can be written.  */
00036 #define       PROT_EXEC      0x01  /* Pages can be executed.  */
00037 
00038 /* Flags contain mapping type, sharing type and options.  */
00039 
00040 /* Mapping type (must choose one and only one of these).  */
00041 #ifdef __USE_BSD
00042 # define MAP_FILE     0x0001       /* Mapped from a file or device.  */
00043 # define MAP_ANON     0x0002       /* Allocated from anonymous virtual memory.  */
00044 # define MAP_TYPE     0x000f       /* Mask for type field.  */
00045 # ifdef __USE_MISC
00046 #  define MAP_ANONYMOUS  MAP_ANON /* Linux name. */
00047 # endif
00048 #endif
00049 
00050 /* Sharing types (must choose one and only one of these).  */
00051 #ifdef __USE_BSD
00052 # define MAP_COPY     0x0020       /* Virtual copy of region at mapping time.  */
00053 #endif
00054 #define       MAP_SHARED     0x0010       /* Share changes.  */
00055 #define       MAP_PRIVATE    0x0000       /* Changes private; copy pages on write.  */
00056 
00057 /* Other flags.  */
00058 #define       MAP_FIXED      0x0100       /* Map address must be exactly as requested. */
00059 #ifdef __USE_BSD
00060 # define MAP_NOEXTEND        0x0200       /* For MAP_FILE, don't change file size.  */
00061 # define MAP_HASSEMPHORE 0x0400    /* Region may contain semaphores.  */
00062 # define MAP_INHERIT  0x0800       /* Region is retained after exec.  */
00063 #endif
00064 
00065 /* Advice to `madvise'.  */
00066 #ifdef __USE_BSD
00067 # define MADV_NORMAL  0     /* No further special treatment.  */
00068 # define MADV_RANDOM  1     /* Expect random page references.  */
00069 # define MADV_SEQUENTIAL 2  /* Expect sequential page references.  */
00070 # define MADV_WILLNEED       3     /* Will need these pages.  */
00071 # define MADV_DONTNEED       4     /* Don't need these pages.  */
00072 #endif
00073 
00074 /* The POSIX people had to invent similar names for the same things.  */
00075 #ifdef __USE_XOPEN2K
00076 # define POSIX_MADV_NORMAL  0 /* No further special treatment.  */
00077 # define POSIX_MADV_RANDOM  1 /* Expect random page references.  */
00078 # define POSIX_MADV_SEQUENTIAL     2 /* Expect sequential page references.  */
00079 # define POSIX_MADV_WILLNEED       3 /* Will need these pages.  */
00080 # define POSIX_MADV_DONTNEED       4 /* Don't need these pages.  */
00081 #endif
00082 
00083 /* Flags to `msync'.  */
00084 #define MS_ASYNC     1             /* Sync memory asynchronously.  */
00085 #define MS_SYNC             0             /* Synchronous memory sync.  */
00086 #define MS_INVALIDATE       2             /* Invalidate the caches.  */
00087 
00088 /* Flags for `mremap'.  */
00089 #ifdef __USE_GNU
00090 # define MREMAP_MAYMOVE     1             /* Mapping address may change.  */
00091 # define MREMAP_FIXED       2             /* Fifth argument sets new address.  */
00092 #endif
00093 
00094 /* Flags for `mlockall' (can be OR'd together).  */
00095 #define MCL_CURRENT  1             /* Lock all currently mapped pages.  */
00096 #define MCL_FUTURE   2             /* Lock all additions to address
00097                                       space.  */