apr__mmap_8h-source.html

来自「apr函数库使用手册」· HTML 代码 · 共 184 行

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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?