mmap.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 1982, 1986, 1993
00003  *      The Regents of the University of California.  All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. All advertising materials mentioning features or use of this software
00014  *    must display the following acknowledgement:
00015  *      This product includes software developed by the University of
00016  *      California, Berkeley and its contributors.
00017  * 4. Neither the name of the University nor the names of its contributors
00018  *    may be used to endorse or promote products derived from this software
00019  *    without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00022  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00024  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00025  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00026  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00027  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00028  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00030  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00031  * SUCH DAMAGE.
00032  *
00033  *      @(#)mman.h      8.2 (Berkeley) 1/9/95
00034  */
00035 #ifndef __POSIX_MMAP_H__
00036 #define __POSIX_MMAP_H__
00037 #include <libc.h>
00038 
00039 /*
00040  * Protections are chosen from these bits, or-ed together
00041  */
00042 #define PROT_NONE       0x00    /* no permissions */
00043 #define PROT_READ       0x01    /* pages can be read */
00044 #define PROT_WRITE      0x02    /* pages can be written */
00045 #define PROT_EXEC       0x04    /* pages can be executed */
00046 
00047 /*
00048  * Flags contain sharing type and options.
00049  * Sharing types; choose one.
00050  */
00051 #define MAP_SHARED      0x0001  /* share changes */
00052 #define MAP_PRIVATE     0x0002  /* changes are private */
00053 
00054 /*
00055  * Other flags
00056  */
00057 #define MAP_FIXED        0x0010 /* map addr must be exactly as requested */
00058 #define MAP_RENAME       0x0020 /* Sun: rename private pages to file */
00059 #define MAP_NORESERVE    0x0040 /* Sun: don't reserve needed swap area */
00060 #define MAP_INHERIT      0x0080 /* region is retained after exec */
00061 #define MAP_NOEXTEND     0x0100 /* for MAP_FILE, don't change file size */
00062 #define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */
00063 
00064 /*
00065  * Mapping type
00066  */
00067 #define MAP_FILE        0x0000  /* map from file (default) */
00068 #define MAP_ANON        0x1000  /* allocated from memory, swap space */
00069 
00070 /*
00071  * Error indicator returned by mmap(2)
00072  */
00073 #define MAP_FAILED      ((void *) -1)   /* mmap() failed */
00074 
00075 /*
00076  * Flags to msync
00077  */
00078 #define MS_ASYNC        0x01    /* perform asynchronous writes */
00079 #define MS_INVALIDATE   0x02    /* invalidate cached data */
00080 #define MS_SYNC         0x04    /* perform synchronous writes */
00081 
00082 /*
00083  * Flags to mlockall
00084  */
00085 #define MCL_CURRENT     0x01    /* lock all pages currently mapped */
00086 #define MCL_FUTURE      0x02    /* lock all pages mapped in the future */
00087 
00088 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
00089 /*
00090  * Advice to madvise
00091  */
00092 #define MADV_NORMAL     0       /* no further special treatment */
00093 #define MADV_RANDOM     1       /* expect random page references */
00094 #define MADV_SEQUENTIAL 2       /* expect sequential page references */
00095 #define MADV_WILLNEED   3       /* will need these pages */
00096 #define MADV_DONTNEED   4       /* dont need these pages */
00097 #define MADV_SPACEAVAIL 5       /* insure that resources are reserved */
00098 #define MADV_FREE       6       /* pages are empty, free them */
00099 /*
00100  * Flags to minherit
00101  */
00102 #define MAP_INHERIT_SHARE       0       /* share with child */
00103 #define MAP_INHERIT_COPY        1       /* copy into child */
00104 #define MAP_INHERIT_NONE        2       /* absent from child */
00105 #define MAP_INHERIT_DONATE_COPY 3       /* copy and delete -- not
00106                                            implemented in UVM */
00107 #define MAP_INHERIT_DEFAULT     MAP_INHERIT_COPY
00108 #endif
00109 
00110 /* PROTO mmap.c */
00111 /* mmap.c */
00112 void *mmap_file(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
00113 int munmap_file(void *addr, size_t len);
00114 int getpagesize(void);
00115 void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
00116 int mprotect(void *addr, size_t len, int prot);
00117 int munmap(void *addr, size_t len);
00118 #endif

Generated on Wed May 24 23:04:17 2006 for LSE/OS by  doxygen 1.4.6