Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 243222a43997d44a8ac787d018c9535c > files > 38

apr-docs-1.2.7-11.el5_6.5.x86_64.rpm

<!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">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li><a href="examples.html"><span>Examples</span></a></li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>Globals</span></a></li>
  </ul></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"><a name="l00001"></a>00001 <span class="comment">/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as</span>
<a name="l00002"></a>00002 <span class="comment"> * applicable.</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span>
<a name="l00005"></a>00005 <span class="comment"> * you may not use this file except in compliance with the License.</span>
<a name="l00006"></a>00006 <span class="comment"> * You may obtain a copy of the License at</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> *     http://www.apache.org/licenses/LICENSE-2.0</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span>
<a name="l00011"></a>00011 <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span>
<a name="l00012"></a>00012 <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<a name="l00013"></a>00013 <span class="comment"> * See the License for the specific language governing permissions and</span>
<a name="l00014"></a>00014 <span class="comment"> * limitations under the License.</span>
<a name="l00015"></a>00015 <span class="comment"> */</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="preprocessor">#ifndef APR_MMAP_H</span>
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define APR_MMAP_H</span>
<a name="l00019"></a>00019 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00020"></a>00020 <span class="comment">/**</span>
<a name="l00021"></a>00021 <span class="comment"> * @file apr_mmap.h</span>
<a name="l00022"></a>00022 <span class="comment"> * @brief APR MMAP routines</span>
<a name="l00023"></a>00023 <span class="comment"> */</span>
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="apr_8h.html">apr.h</a>"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="apr__pools_8h.html">apr_pools.h</a>"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="apr__errno_8h.html">apr_errno.h</a>"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="apr__ring_8h.html">apr_ring.h</a>"</span>
<a name="l00029"></a>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>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#ifdef BEOS</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span><span class="preprocessor">#include &lt;kernel/OS.h&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#endif</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> {
<a name="l00037"></a>00037 <span class="preprocessor">#endif </span><span class="comment">/* __cplusplus */</span>
<a name="l00038"></a>00038 <span class="comment"></span>
<a name="l00039"></a>00039 <span class="comment">/**</span>
<a name="l00040"></a>00040 <span class="comment"> * @defgroup apr_mmap MMAP (Memory Map) Routines</span>
<a name="l00041"></a>00041 <span class="comment"> * @ingroup APR </span>
<a name="l00042"></a>00042 <span class="comment"> * @{</span>
<a name="l00043"></a>00043 <span class="comment"> */</span>
<a name="l00044"></a>00044 <span class="comment"></span>
<a name="l00045"></a>00045 <span class="comment">/** MMap opened for reading */</span>
<a name="l00046"></a><a class="code" href="group__apr__mmap.html#g3b178eb8bdd4ba1dada0bbd64b42d350">00046</a> <span class="preprocessor">#define APR_MMAP_READ    1</span>
<a name="l00047"></a>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#g550403adecdeea91d17c615b0f74e3d5">00048</a> <span class="preprocessor">#define APR_MMAP_WRITE   2</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00050"></a>00050 <span class="comment">/** @see apr_mmap_t */</span>
<a name="l00051"></a><a class="code" href="group__apr__mmap.html#g69d9aa84488809d9d1db0482eb087e2d">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#g69d9aa84488809d9d1db0482eb087e2d">apr_mmap_t</a>;
<a name="l00052"></a>00052 <span class="comment"></span>
<a name="l00053"></a>00053 <span class="comment">/**</span>
<a name="l00054"></a>00054 <span class="comment"> * @remark</span>
<a name="l00055"></a>00055 <span class="comment"> * As far as I can tell the only really sane way to store an MMAP is as a</span>
<a name="l00056"></a>00056 <span class="comment"> * void * and a length.  BeOS requires this area_id, but that's just a little</span>
<a name="l00057"></a>00057 <span class="comment"> * something extra.  I am exposing this type, because it doesn't make much</span>
<a name="l00058"></a>00058 <span class="comment"> * sense to keep it private, and opening it up makes some stuff easier in</span>
<a name="l00059"></a>00059 <span class="comment"> * Apache.</span>
<a name="l00060"></a>00060 <span class="comment"> */</span><span class="comment"></span>
<a name="l00061"></a>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#g69d9aa84488809d9d1db0482eb087e2d">apr_mmap_t</a> {<span class="comment"></span>
<a name="l00063"></a>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#0dfcec71424a41c5d18936bac624de31">00064</a>     <a class="code" href="group__apr__pools.html#g06f17a7732f2d04d8ce7010fbb057a8b">apr_pool_t</a> *<a class="code" href="structapr__mmap__t.html#0dfcec71424a41c5d18936bac624de31">cntxt</a>;
<a name="l00065"></a>00065 <span class="preprocessor">#ifdef BEOS</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span><span class="comment">    /** An area ID.  Only valid on BeOS */</span>
<a name="l00067"></a>00067     area_id area;
<a name="l00068"></a>00068 <span class="preprocessor">#endif</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="preprocessor">#ifdef WIN32</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span><span class="comment">    /** The handle of the file mapping */</span>
<a name="l00071"></a>00071     HANDLE mhandle;<span class="comment"></span>
<a name="l00072"></a>00072 <span class="comment">    /** The start of the real memory page area (mapped view) */</span>
<a name="l00073"></a>00073     <span class="keywordtype">void</span> *mv;<span class="comment"></span>
<a name="l00074"></a>00074 <span class="comment">    /** The physical start, size and offset */</span>
<a name="l00075"></a>00075     apr_off_t  pstart;
<a name="l00076"></a>00076     apr_size_t psize;
<a name="l00077"></a>00077     apr_off_t  poffset;
<a name="l00078"></a>00078 <span class="preprocessor">#endif</span>
<a name="l00079"></a>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#50d4554d29ff3583153d2938a001a1f2">00080</a>     <span class="keywordtype">void</span> *<a class="code" href="structapr__mmap__t.html#50d4554d29ff3583153d2938a001a1f2">mm</a>;<span class="comment"></span>
<a name="l00081"></a>00081 <span class="comment">    /** The amount of data in the mmap */</span>
<a name="l00082"></a><a class="code" href="structapr__mmap__t.html#c8272516a8346e7ef0b3ecb9f16249ba">00082</a>     apr_size_t <a class="code" href="structapr__mmap__t.html#c8272516a8346e7ef0b3ecb9f16249ba">size</a>;<span class="comment"></span>
<a name="l00083"></a>00083 <span class="comment">    /** ring of apr_mmap_t's that reference the same</span>
<a name="l00084"></a>00084 <span class="comment">     * mmap'ed region; acts in place of a reference count */</span>
<a name="l00085"></a>00085     <a class="code" href="structapr__mmap__t.html#6f577d12bcef8a5149e210b0fd5956ac">APR_RING_ENTRY</a>(<a class="code" href="group__apr__mmap.html#g69d9aa84488809d9d1db0482eb087e2d">apr_mmap_t</a>) link;
<a name="l00086"></a>00086 };
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 <span class="preprocessor">#if APR_HAS_MMAP || defined(DOXYGEN)</span>
<a name="l00089"></a>00089 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00090"></a>00090 <span class="comment">/** @def APR_MMAP_THRESHOLD </span>
<a name="l00091"></a>00091 <span class="comment"> * Files have to be at least this big before they're mmap()d.  This is to deal</span>
<a name="l00092"></a>00092 <span class="comment"> * with systems where the expense of doing an mmap() and an munmap() outweighs</span>
<a name="l00093"></a>00093 <span class="comment"> * the benefit for small files.  It shouldn't be set lower than 1.</span>
<a name="l00094"></a>00094 <span class="comment"> */</span>
<a name="l00095"></a>00095 <span class="preprocessor">#ifdef MMAP_THRESHOLD</span>
<a name="l00096"></a>00096 <span class="preprocessor"></span><span class="preprocessor">#  define APR_MMAP_THRESHOLD              MMAP_THRESHOLD</span>
<a name="l00097"></a>00097 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00098"></a>00098 <span class="preprocessor"></span><span class="preprocessor">#  ifdef SUNOS4</span>
<a name="l00099"></a>00099 <span class="preprocessor"></span><span class="preprocessor">#    define APR_MMAP_THRESHOLD            (8*1024)</span>
<a name="l00100"></a>00100 <span class="preprocessor"></span><span class="preprocessor">#  else</span>
<a name="l00101"></a><a class="code" href="group__apr__mmap.html#g6d912948d6996ffe5d448f27babf16ad">00101</a> <span class="preprocessor"></span><span class="preprocessor">#    define APR_MMAP_THRESHOLD            1</span>
<a name="l00102"></a>00102 <span class="preprocessor"></span><span class="preprocessor">#  endif </span><span class="comment">/* SUNOS4 */</span>
<a name="l00103"></a>00103 <span class="preprocessor">#endif </span><span class="comment">/* MMAP_THRESHOLD */</span>
<a name="l00104"></a>00104 <span class="comment"></span>
<a name="l00105"></a>00105 <span class="comment">/** @def APR_MMAP_LIMIT</span>
<a name="l00106"></a>00106 <span class="comment"> * Maximum size of MMap region</span>
<a name="l00107"></a>00107 <span class="comment"> */</span>
<a name="l00108"></a>00108 <span class="preprocessor">#ifdef MMAP_LIMIT</span>
<a name="l00109"></a>00109 <span class="preprocessor"></span><span class="preprocessor">#  define APR_MMAP_LIMIT                  MMAP_LIMIT</span>
<a name="l00110"></a>00110 <span class="preprocessor"></span><span class="preprocessor">#else</span>
<a name="l00111"></a><a class="code" href="group__apr__mmap.html#ge8414d1cdeacfaec55c2ef3b93722a84">00111</a> <span class="preprocessor"></span><span class="preprocessor">#  define APR_MMAP_LIMIT                  (4*1024*1024)</span>
<a name="l00112"></a>00112 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* MMAP_LIMIT */</span>
<a name="l00113"></a>00113 <span class="comment"></span>
<a name="l00114"></a>00114 <span class="comment">/** Can this file be MMaped */</span>
<a name="l00115"></a><a class="code" href="group__apr__mmap.html#g7b2ff96acf96a27aa8e54076110b5b9a">00115</a> <span class="preprocessor">#define APR_MMAP_CANDIDATE(filelength) \</span>
<a name="l00116"></a>00116 <span class="preprocessor">    ((filelength &gt;= APR_MMAP_THRESHOLD) &amp;&amp; (filelength &lt; APR_MMAP_LIMIT))</span>
<a name="l00117"></a>00117 <span class="preprocessor"></span>
<a name="l00118"></a>00118 <span class="comment">/*   Function definitions */</span>
<a name="l00119"></a>00119 <span class="comment"></span>
<a name="l00120"></a>00120 <span class="comment">/** </span>
<a name="l00121"></a>00121 <span class="comment"> * Create a new mmap'ed file out of an existing APR file.</span>
<a name="l00122"></a>00122 <span class="comment"> * @param newmmap The newly created mmap'ed file.</span>
<a name="l00123"></a>00123 <span class="comment"> * @param file The file turn into an mmap.</span>
<a name="l00124"></a>00124 <span class="comment"> * @param offset The offset into the file to start the data pointer at.</span>
<a name="l00125"></a>00125 <span class="comment"> * @param size The size of the file</span>
<a name="l00126"></a>00126 <span class="comment"> * @param flag bit-wise or of:</span>
<a name="l00127"></a>00127 <span class="comment"> * &lt;PRE&gt;</span>
<a name="l00128"></a>00128 <span class="comment"> *          APR_MMAP_READ       MMap opened for reading</span>
<a name="l00129"></a>00129 <span class="comment"> *          APR_MMAP_WRITE      MMap opened for writing</span>
<a name="l00130"></a>00130 <span class="comment"> * &lt;/PRE&gt;</span>
<a name="l00131"></a>00131 <span class="comment"> * @param cntxt The pool to use when creating the mmap.</span>
<a name="l00132"></a>00132 <span class="comment"> */</span>
<a name="l00133"></a>00133 <a class="code" href="group__apr__platform.html#g4a5cbc739c4e19ab450020163d0899d4">APR_DECLARE</a>(<a class="code" href="group__apr__errno.html#g4cf2ddae3efce70c508ac7fefc1c47f7">apr_status_t</a>) <a class="code" href="group__apr__mmap.html#gc95e26c79144f9dde2fcefd167f9d302">apr_mmap_create</a>(<a class="code" href="group__apr__mmap.html#g69d9aa84488809d9d1db0482eb087e2d">apr_mmap_t</a> **newmmap, 
<a name="l00134"></a>00134                                           <a class="code" href="group__apr__file__io.html#g804ab64a6f58ddcc3da8d9f54b6f51c2">apr_file_t</a> *file, apr_off_t offset,
<a name="l00135"></a>00135                                           apr_size_t <a class="code" href="structapr__mmap__t.html#c8272516a8346e7ef0b3ecb9f16249ba">size</a>, apr_int32_t flag,
<a name="l00136"></a>00136                                           <a class="code" href="group__apr__pools.html#g06f17a7732f2d04d8ce7010fbb057a8b">apr_pool_t</a> *<a class="code" href="structapr__mmap__t.html#0dfcec71424a41c5d18936bac624de31">cntxt</a>);
<a name="l00137"></a>00137 <span class="comment"></span>
<a name="l00138"></a>00138 <span class="comment">/**</span>
<a name="l00139"></a>00139 <span class="comment"> * Duplicate the specified MMAP.</span>
<a name="l00140"></a>00140 <span class="comment"> * @param new_mmap The structure to duplicate into. </span>
<a name="l00141"></a>00141 <span class="comment"> * @param old_mmap The mmap to duplicate.</span>
<a name="l00142"></a>00142 <span class="comment"> * @param p The pool to use for new_mmap.</span>
<a name="l00143"></a>00143 <span class="comment"> */</span>         
<a name="l00144"></a>00144 <a class="code" href="group__apr__platform.html#g4a5cbc739c4e19ab450020163d0899d4">APR_DECLARE</a>(<a class="code" href="group__apr__errno.html#g4cf2ddae3efce70c508ac7fefc1c47f7">apr_status_t</a>) <a class="code" href="group__apr__mmap.html#gad645ce7da25f7bfee2daccbd0f0475b">apr_mmap_dup</a>(<a class="code" href="group__apr__mmap.html#g69d9aa84488809d9d1db0482eb087e2d">apr_mmap_t</a> **new_mmap,
<a name="l00145"></a>00145                                        <a class="code" href="group__apr__mmap.html#g69d9aa84488809d9d1db0482eb087e2d">apr_mmap_t</a> *old_mmap,
<a name="l00146"></a>00146                                        <a class="code" href="group__apr__pools.html#g06f17a7732f2d04d8ce7010fbb057a8b">apr_pool_t</a> *p);
<a name="l00147"></a>00147 <span class="comment"></span>
<a name="l00148"></a>00148 <span class="comment">/**</span>
<a name="l00149"></a>00149 <span class="comment"> * Remove a mmap'ed.</span>
<a name="l00150"></a>00150 <span class="comment"> * @param mm The mmap'ed file.</span>
<a name="l00151"></a>00151 <span class="comment"> */</span>
<a name="l00152"></a>00152 <a class="code" href="group__apr__platform.html#g4a5cbc739c4e19ab450020163d0899d4">APR_DECLARE</a>(<a class="code" href="group__apr__errno.html#g4cf2ddae3efce70c508ac7fefc1c47f7">apr_status_t</a>) <a class="code" href="group__apr__mmap.html#gee1ce85626fa74ec5624c5cb4d33ad68">apr_mmap_delete</a>(<a class="code" href="group__apr__mmap.html#g69d9aa84488809d9d1db0482eb087e2d">apr_mmap_t</a> *<a class="code" href="structapr__mmap__t.html#50d4554d29ff3583153d2938a001a1f2">mm</a>);
<a name="l00153"></a>00153 <span class="comment"></span>
<a name="l00154"></a>00154 <span class="comment">/** </span>
<a name="l00155"></a>00155 <span class="comment"> * Move the pointer into the mmap'ed file to the specified offset.</span>
<a name="l00156"></a>00156 <span class="comment"> * @param addr The pointer to the offset specified.</span>
<a name="l00157"></a>00157 <span class="comment"> * @param mm The mmap'ed file.</span>
<a name="l00158"></a>00158 <span class="comment"> * @param offset The offset to move to.</span>
<a name="l00159"></a>00159 <span class="comment"> */</span>
<a name="l00160"></a>00160 <a class="code" href="group__apr__platform.html#g4a5cbc739c4e19ab450020163d0899d4">APR_DECLARE</a>(<a class="code" href="group__apr__errno.html#g4cf2ddae3efce70c508ac7fefc1c47f7">apr_status_t</a>) <a class="code" href="group__apr__mmap.html#gdb8d2b0d952aa60ca0590bebf982cd98">apr_mmap_offset</a>(<span class="keywordtype">void</span> **addr, <a class="code" href="group__apr__mmap.html#g69d9aa84488809d9d1db0482eb087e2d">apr_mmap_t</a> *mm, 
<a name="l00161"></a>00161                                           apr_off_t offset);
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 <span class="preprocessor">#endif </span><span class="comment">/* APR_HAS_MMAP */</span>
<a name="l00164"></a>00164 <span class="comment"></span>
<a name="l00165"></a>00165 <span class="comment">/** @} */</span>
<a name="l00166"></a>00166 
<a name="l00167"></a>00167 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00168"></a>00168 <span class="preprocessor"></span>}
<a name="l00169"></a>00169 <span class="preprocessor">#endif</span>
<a name="l00170"></a>00170 <span class="preprocessor"></span>
<a name="l00171"></a>00171 <span class="preprocessor">#endif  </span><span class="comment">/* ! APR_MMAP_H */</span>
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue May 31 12:43:38 2011 for Apache Portable Runtime by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
</body>
</html>