<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Apache Portable Runtime: apr_mmap.h Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.3.9.1 --> <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a></div> <div class="nav"> <a class="el" href="dir_000000.html">home</a> / <a class="el" href="dir_000001.html">oden</a> / <a class="el" href="dir_000002.html">RPM</a> / <a class="el" href="dir_000003.html">BUILD</a> / <a class="el" href="dir_000004.html">apr-1.1.1</a> / <a class="el" href="dir_000005.html">include</a></div> <h1>apr_mmap.h</h1><a href="apr__mmap_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="comment">/* Copyright 2000-2004 The Apache Software Foundation</span> 00002 <span class="comment"> *</span> 00003 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span> 00004 <span class="comment"> * you may not use this file except in compliance with the License.</span> 00005 <span class="comment"> * You may obtain a copy of the License at</span> 00006 <span class="comment"> *</span> 00007 <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span> 00008 <span class="comment"> *</span> 00009 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span> 00010 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span> 00011 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span> 00012 <span class="comment"> * See the License for the specific language governing permissions and</span> 00013 <span class="comment"> * limitations under the License.</span> 00014 <span class="comment"> */</span> 00015 00016 <span class="preprocessor">#ifndef APR_MMAP_H</span> 00017 <span class="preprocessor"></span><span class="preprocessor">#define APR_MMAP_H</span> 00018 <span class="preprocessor"></span><span class="comment"></span> 00019 <span class="comment">/**</span> 00020 <span class="comment"> * @file apr_mmap.h</span> 00021 <span class="comment"> * @brief APR MMAP routines</span> 00022 <span class="comment"> */</span> 00023 00024 <span class="preprocessor">#include "<a class="code" href="apr_8h.html">apr.h</a>"</span> 00025 <span class="preprocessor">#include "<a class="code" href="apr__pools_8h.html">apr_pools.h</a>"</span> 00026 <span class="preprocessor">#include "<a class="code" href="apr__errno_8h.html">apr_errno.h</a>"</span> 00027 <span class="preprocessor">#include "<a class="code" href="apr__ring_8h.html">apr_ring.h</a>"</span> 00028 <span class="preprocessor">#include "<a class="code" href="apr__file__io_8h.html">apr_file_io.h</a>"</span> <span class="comment">/* for apr_file_t */</span> 00029 00030 <span class="preprocessor">#ifdef BEOS</span> 00031 <span class="preprocessor"></span><span class="preprocessor">#include <kernel/OS.h></span> 00032 <span class="preprocessor">#endif</span> 00033 <span class="preprocessor"></span> 00034 <span class="preprocessor">#ifdef __cplusplus</span> 00035 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> { 00036 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span> 00037 <span class="comment"></span> 00038 <span class="comment">/**</span> 00039 <span class="comment"> * @defgroup apr_mmap MMAP (Memory Map) Routines</span> 00040 <span class="comment"> * @ingroup APR </span> 00041 <span class="comment"> * @{</span> 00042 <span class="comment"> */</span> 00043 <span class="comment"></span> 00044 <span class="comment">/** MMap opened for reading */</span> <a name="l00045"></a><a class="code" href="group__apr__mmap.html#ga5">00045</a> <span class="preprocessor">#define APR_MMAP_READ 1</span> 00046 <span class="preprocessor"></span><span class="comment">/** MMap opened for writing */</span> <a name="l00047"></a><a class="code" href="group__apr__mmap.html#ga6">00047</a> <span class="preprocessor">#define APR_MMAP_WRITE 2</span> 00048 <span class="preprocessor"></span><span class="comment"></span> 00049 <span class="comment">/** @see apr_mmap_t */</span> <a name="l00050"></a><a class="code" href="group__apr__mmap.html#ga0">00050</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structapr__mmap__t.html">apr_mmap_t</a> <a class="code" href="group__apr__mmap.html#ga0">apr_mmap_t</a>; 00051 <span class="comment"></span> 00052 <span class="comment">/**</span> 00053 <span class="comment"> * @remark</span> 00054 <span class="comment"> * As far as I can tell the only really sane way to store an MMAP is as a</span> 00055 <span class="comment"> * void * and a length. BeOS requires this area_id, but that's just a little</span> 00056 <span class="comment"> * something extra. I am exposing this type, because it doesn't make much</span> 00057 <span class="comment"> * sense to keep it private, and opening it up makes some stuff easier in</span> 00058 <span class="comment"> * Apache.</span> 00059 <span class="comment"> */</span><span class="comment"></span> 00060 <span class="comment">/** The MMAP structure */</span> <a name="l00061"></a><a class="code" href="structapr__mmap__t.html">00061</a> <span class="keyword">struct </span><a class="code" href="group__apr__mmap.html#ga0">apr_mmap_t</a> {<span class="comment"></span> 00062 <span class="comment"> /** The pool the mmap structure was allocated out of. */</span> <a name="l00063"></a><a class="code" href="structapr__mmap__t.html#o0">00063</a> <a class="code" href="group__apr__pools.html#ga0">apr_pool_t</a> *cntxt; 00064 <span class="preprocessor">#ifdef BEOS</span> 00065 <span class="preprocessor"></span><span class="comment"> /** An area ID. Only valid on BeOS */</span> 00066 area_id area; 00067 <span class="preprocessor">#endif</span> 00068 <span class="preprocessor"></span><span class="preprocessor">#ifdef WIN32</span> 00069 <span class="preprocessor"></span><span class="comment"> /** The handle of the file mapping */</span> 00070 HANDLE mhandle;<span class="comment"></span> 00071 <span class="comment"> /** The start of the real memory page area (mapped view) */</span> 00072 <span class="keywordtype">void</span> *mv;<span class="comment"></span> 00073 <span class="comment"> /** The physical start, size and offset */</span> 00074 apr_off_t pstart; 00075 apr_size_t psize; 00076 apr_off_t poffset; 00077 <span class="preprocessor">#endif</span> 00078 <span class="preprocessor"></span><span class="comment"> /** The start of the memory mapped area */</span> <a name="l00079"></a><a class="code" href="structapr__mmap__t.html#o1">00079</a> <span class="keywordtype">void</span> *mm;<span class="comment"></span> 00080 <span class="comment"> /** The amount of data in the mmap */</span> <a name="l00081"></a><a class="code" href="structapr__mmap__t.html#o2">00081</a> apr_size_t size;<span class="comment"></span> 00082 <span class="comment"> /** ring of apr_mmap_t's that reference the same</span> 00083 <span class="comment"> * mmap'ed region; acts in place of a reference count */</span> 00084 <a class="code" href="group__apr__ring.html#ga0">APR_RING_ENTRY</a>(apr_mmap_t) link; 00085 }; 00086 00087 #if APR_HAS_MMAP || defined(DOXYGEN) 00088 <span class="comment"></span> 00089 <span class="comment">/** @def APR_MMAP_THRESHOLD </span> 00090 <span class="comment"> * Files have to be at least this big before they're mmap()d. This is to deal</span> 00091 <span class="comment"> * with systems where the expense of doing an mmap() and an munmap() outweighs</span> 00092 <span class="comment"> * the benefit for small files. It shouldn't be set lower than 1.</span> 00093 <span class="comment"> */</span> 00094 #ifdef MMAP_THRESHOLD 00095 # define APR_MMAP_THRESHOLD MMAP_THRESHOLD 00096 #else 00097 # ifdef SUNOS4 00098 # define APR_MMAP_THRESHOLD (8*1024) 00099 # else <a name="l00100"></a><a class="code" href="group__apr__mmap.html#ga7">00100</a> # define APR_MMAP_THRESHOLD 1 00101 # endif <span class="comment">/* SUNOS4 */</span> 00102 #endif <span class="comment">/* MMAP_THRESHOLD */</span> 00103 <span class="comment"></span> 00104 <span class="comment">/** @def APR_MMAP_LIMIT</span> 00105 <span class="comment"> * Maximum size of MMap region</span> 00106 <span class="comment"> */</span> 00107 #ifdef MMAP_LIMIT 00108 # define APR_MMAP_LIMIT MMAP_LIMIT 00109 #else <a name="l00110"></a><a class="code" href="group__apr__mmap.html#ga8">00110</a> # define APR_MMAP_LIMIT (4*1024*1024) 00111 #endif <span class="comment">/* MMAP_LIMIT */</span> 00112 <span class="comment"></span> 00113 <span class="comment">/** Can this file be MMaped */</span> <a name="l00114"></a><a class="code" href="group__apr__mmap.html#ga9">00114</a> #define APR_MMAP_CANDIDATE(filelength) \ 00115 ((filelength >= APR_MMAP_THRESHOLD) && (filelength < APR_MMAP_LIMIT)) 00116 00117 <span class="comment">/* Function definitions */</span> 00118 <span class="comment"></span> 00119 <span class="comment">/** </span> 00120 <span class="comment"> * Create a new mmap'ed file out of an existing APR file.</span> 00121 <span class="comment"> * @param newmmap The newly created mmap'ed file.</span> 00122 <span class="comment"> * @param file The file turn into an mmap.</span> 00123 <span class="comment"> * @param offset The offset into the file to start the data pointer at.</span> 00124 <span class="comment"> * @param size The size of the file</span> 00125 <span class="comment"> * @param flag bit-wise or of:</span> 00126 <span class="comment"> * <PRE></span> 00127 <span class="comment"> * APR_MMAP_READ MMap opened for reading</span> 00128 <span class="comment"> * APR_MMAP_WRITE MMap opened for writing</span> 00129 <span class="comment"> * </PRE></span> 00130 <span class="comment"> * @param cntxt The pool to use when creating the mmap.</span> 00131 <span class="comment"> */</span> 00132 APR_DECLARE(apr_status_t) apr_mmap_create(apr_mmap_t **newmmap, 00133 apr_file_t *file, apr_off_t offset, 00134 apr_size_t size, apr_int32_t flag, 00135 apr_pool_t *cntxt); 00136 <span class="comment"></span> 00137 <span class="comment">/**</span> 00138 <span class="comment"> * Duplicate the specified MMAP.</span> 00139 <span class="comment"> * @param new_mmap The structure to duplicate into. </span> 00140 <span class="comment"> * @param old_mmap The mmap to duplicate.</span> 00141 <span class="comment"> * @param p The pool to use for new_mmap.</span> 00142 <span class="comment"> */</span> 00143 APR_DECLARE(apr_status_t) apr_mmap_dup(apr_mmap_t **new_mmap, 00144 apr_mmap_t *old_mmap, 00145 apr_pool_t *p); 00146 <span class="comment"></span> 00147 <span class="comment">/**</span> 00148 <span class="comment"> * Remove a mmap'ed.</span> 00149 <span class="comment"> * @param mm The mmap'ed file.</span> 00150 <span class="comment"> */</span> 00151 APR_DECLARE(apr_status_t) apr_mmap_delete(apr_mmap_t *mm); 00152 <span class="comment"></span> 00153 <span class="comment">/** </span> 00154 <span class="comment"> * Move the pointer into the mmap'ed file to the specified offset.</span> 00155 <span class="comment"> * @param addr The pointer to the offset specified.</span> 00156 <span class="comment"> * @param mm The mmap'ed file.</span> 00157 <span class="comment"> * @param offset The offset to move to.</span> 00158 <span class="comment"> */</span> 00159 APR_DECLARE(apr_status_t) apr_mmap_offset(<span class="keywordtype">void</span> **addr, apr_mmap_t *mm, 00160 apr_off_t offset); 00161 00162 #endif <span class="comment">/* APR_HAS_MMAP */</span> 00163 <span class="comment"></span> 00164 <span class="comment">/** @} */</span> 00165 00166 #ifdef __cplusplus 00167 } 00168 #endif 00169 00170 #endif <span class="comment">/* ! APR_MMAP_H */</span> </pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Mar 20 19:52:26 2005 for Apache Portable Runtime by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address> </body> </html>