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