| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>db_env_set_func_region_map</title> |
| 7 | <link rel="stylesheet" href="apiReference.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> |
| 10 | <link rel="up" href="setfunc.html" title="Appendix C. Berkeley DB Application Space Static Functions" /> |
| 11 | <link rel="prev" href="db_env_set_func_realloc.html" title="db_env_set_func_realloc" /> |
| 12 | <link rel="next" href="db_env_set_func_rename.html" title="db_env_set_func_rename" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">db_env_set_func_region_map</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="db_env_set_func_realloc.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Appendix C. |
| 26 | Berkeley DB Application Space Static Functions |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="db_env_set_func_rename.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="db_env_set_func_region_map"></a>db_env_set_func_region_map</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int |
| 44 | db_env_set_func_region_map(int (*func_region_map)(DB_ENV *dbenv, |
| 45 | char *path, size_t len, int *is_create, void **addr), |
| 46 | int (*func_region_unmap)(DB_ENV *dbenv, void *addr)); </pre> |
| 47 | <p> |
| 48 | The Berkeley DB library optionally uses the ability to create shared |
| 49 | memory regions (which may or may not be backed by physical files). |
| 50 | The memory will be used as a shared memory region for synchronization |
| 51 | between Berkeley DB threads/processes; while the returned memory may |
| 52 | be of any kind (for example, anonymous memory), it must be able to |
| 53 | support semaphores. |
| 54 | </p> |
| 55 | <p> |
| 56 | The <code class="function">db_env_set_func_region_map()</code> function configures all operations |
| 57 | performed by a process and all of its threads of control, not |
| 58 | operations confined to a single database environment. |
| 59 | </p> |
| 60 | <p> |
| 61 | Although the <code class="function">db_env_set_func_region_map()</code> function may be called at any |
| 62 | time during the life of the application, it should normally be called |
| 63 | before making calls to the <a class="xref" href="envcreate.html" title="db_env_create">db_env_create</a> or |
| 64 | <a class="xref" href="dbcreate.html" title="db_create">db_create</a> methods. |
| 65 | </p> |
| 66 | <p> |
| 67 | The <code class="function">db_env_set_func_region_map()</code> <span> |
| 68 | function returns a non-zero error value on failure and 0 on success. |
| 69 | </span> |
| 70 | </p> |
| 71 | <div class="sect2" lang="en" xml:lang="en"> |
| 72 | <div class="titlepage"> |
| 73 | <div> |
| 74 | <div> |
| 75 | <h3 class="title"><a id="idp55696776"></a>Parameters</h3> |
| 76 | </div> |
| 77 | </div> |
| 78 | </div> |
| 79 | <div class="sect3" lang="en" xml:lang="en"> |
| 80 | <div class="titlepage"> |
| 81 | <div> |
| 82 | <div> |
| 83 | <h4 class="title"><a id="idp55696968"></a>func_region_map</h4> |
| 84 | </div> |
| 85 | </div> |
| 86 | </div> |
| 87 | <p> |
| 88 | The <span class="bold"><strong>func_region_map</strong></span> parameter is the |
| 89 | function which creates shared memory regions. The function takes 5 |
| 90 | parameters: |
| 91 | </p> |
| 92 | <div class="itemizedlist"> |
| 93 | <ul type="disc"> |
| 94 | <li> |
| 95 | <p> |
| 96 | <span class="bold"><strong>dbenv</strong></span> |
| 97 | </p> |
| 98 | <p> |
| 99 | The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing |
| 100 | database environment handle. This handle is provided to uniquely |
| 101 | identify a shared memory region: the <span class="bold"><strong>dbenv</strong></span> parameter and the path are a unique |
| 102 | identifier pair for mapping any new region, and the <span class="bold"><strong>dbenv</strong></span> parameter and the address are a unique |
| 103 | identifier pair for unmapping any region. |
| 104 | </p> |
| 105 | </li> |
| 106 | <li> |
| 107 | <p> |
| 108 | <span class="bold"><strong>path</strong></span> |
| 109 | </p> |
| 110 | <p> |
| 111 | The <span class="bold"><strong>path</strong></span> parameter is the name of the |
| 112 | region. Repeated requests for the shared regions of the same name, in |
| 113 | the same database environment, should return a reference to the same |
| 114 | memory. |
| 115 | </p> |
| 116 | </li> |
| 117 | <li> |
| 118 | <p> |
| 119 | <span class="bold"><strong>len</strong></span> |
| 120 | </p> |
| 121 | <p> |
| 122 | The <span class="bold"><strong>len</strong></span> parameter is the length, in |
| 123 | bytes, needed for the region. |
| 124 | </p> |
| 125 | </li> |
| 126 | <li> |
| 127 | <p> |
| 128 | <span class="bold"><strong>is_create</strong></span> |
| 129 | </p> |
| 130 | <p> |
| 131 | The memory referenced by the <span class="bold"><strong>is_create</strong></span> parameter will be non-zero if flags |
| 132 | to Berkeley DB allowed creation of the mapped region; the memory |
| 133 | referenced by the <span class="bold"><strong>is_create</strong></span> parameter |
| 134 | must be set to non-zero if the region is created by the <span class="bold"><strong>func_region_map</strong></span> function, and set to zero if |
| 135 | the region is not created by the function. This returned information |
| 136 | will determine if the region is subsequently initialized by Berkeley |
| 137 | DB. |
| 138 | </p> |
| 139 | </li> |
| 140 | <li> |
| 141 | <p> |
| 142 | <span class="bold"><strong>addr</strong></span> |
| 143 | </p> |
| 144 | <p> |
| 145 | The <span class="bold"><strong>addr</strong></span> parameter is the memory |
| 146 | location into which a pointer to the region or mapped file is |
| 147 | returned. |
| 148 | </p> |
| 149 | </li> |
| 150 | </ul> |
| 151 | </div> |
| 152 | </div> |
| 153 | <div class="sect3" lang="en" xml:lang="en"> |
| 154 | <div class="titlepage"> |
| 155 | <div> |
| 156 | <div> |
| 157 | <h4 class="title"><a id="idp55703784"></a>func_region_unmap</h4> |
| 158 | </div> |
| 159 | </div> |
| 160 | </div> |
| 161 | <p> |
| 162 | The <span class="bold"><strong>func_region_unmap</strong></span> parameter is |
| 163 | the function which unmaps a shared memory region. The function takes |
| 164 | 2 parameters: |
| 165 | </p> |
| 166 | <div class="itemizedlist"> |
| 167 | <ul type="disc"> |
| 168 | <li> |
| 169 | <p> |
| 170 | <span class="bold"><strong>dbenv</strong></span> |
| 171 | </p> |
| 172 | <p> |
| 173 | The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing |
| 174 | database environment handle. |
| 175 | </p> |
| 176 | </li> |
| 177 | <li> |
| 178 | <p> |
| 179 | <span class="bold"><strong>addr</strong></span> |
| 180 | </p> |
| 181 | <p> |
| 182 | The <span class="bold"><strong>addr</strong></span> parameter is the value |
| 183 | returned by the <span class="bold"><strong>func_region_map</strong></span> |
| 184 | function when the region was mapped into memory. |
| 185 | </p> |
| 186 | </li> |
| 187 | </ul> |
| 188 | </div> |
| 189 | </div> |
| 190 | </div> |
| 191 | <div class="sect2" lang="en" xml:lang="en"> |
| 192 | <div class="titlepage"> |
| 193 | <div> |
| 194 | <div> |
| 195 | <h3 class="title"><a id="idp55701840"></a>See Also</h3> |
| 196 | </div> |
| 197 | </div> |
| 198 | </div> |
| 199 | <p> |
| 200 | <a href="../../programmer_reference/program_runtime.html" class="olink">Run-time configuration</a> |
| 201 | </p> |
| 202 | </div> |
| 203 | </div> |
| 204 | <div class="navfooter"> |
| 205 | <hr /> |
| 206 | <table width="100%" summary="Navigation footer"> |
| 207 | <tr> |
| 208 | <td width="40%" align="left"><a accesskey="p" href="db_env_set_func_realloc.html">Prev</a> </td> |
| 209 | <td width="20%" align="center"> |
| 210 | <a accesskey="u" href="setfunc.html">Up</a> |
| 211 | </td> |
| 212 | <td width="40%" align="right"> <a accesskey="n" href="db_env_set_func_rename.html">Next</a></td> |
| 213 | </tr> |
| 214 | <tr> |
| 215 | <td width="40%" align="left" valign="top">db_env_set_func_realloc </td> |
| 216 | <td width="20%" align="center"> |
| 217 | <a accesskey="h" href="index.html">Home</a> |
| 218 | </td> |
| 219 | <td width="40%" align="right" valign="top"> db_env_set_func_rename</td> |
| 220 | </tr> |
| 221 | </table> |
| 222 | </div> |
| 223 | </body> |
| 224 | </html> |