1<html lang="en"> 2<head> 3<title>__env_lock - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Stdlib.html#Stdlib" title="Stdlib"> 9<link rel="prev" href="ecvt.html#ecvt" title="ecvt"> 10<link rel="next" href="gvcvt.html#gvcvt" title="gvcvt"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<meta http-equiv="Content-Style-Type" content="text/css"> 13<style type="text/css"><!-- 14 pre.display { font-family:inherit } 15 pre.format { font-family:inherit } 16 pre.smalldisplay { font-family:inherit; font-size:smaller } 17 pre.smallformat { font-family:inherit; font-size:smaller } 18 pre.smallexample { font-size:smaller } 19 pre.smalllisp { font-size:smaller } 20 span.sc { font-variant:small-caps } 21 span.roman { font-family:serif; font-weight:normal; } 22 span.sansserif { font-family:sans-serif; font-weight:normal; } 23--></style> 24<link rel="stylesheet" type="text/css" href="../cs.css"> 25</head> 26<body> 27<div class="node"> 28<a name="__env_lock"></a> 29<a name="g_t_005f_005fenv_005flock"></a> 30<p> 31Next: <a rel="next" accesskey="n" href="gvcvt.html#gvcvt">gvcvt</a>, 32Previous: <a rel="previous" accesskey="p" href="ecvt.html#ecvt">ecvt</a>, 33Up: <a rel="up" accesskey="u" href="Stdlib.html#Stdlib">Stdlib</a> 34<hr> 35</div> 36 37<h3 class="section">2.16 <code>__env_lock</code>, <code>__env_unlock</code>—lock environ variable</h3> 38 39<p><a name="index-g_t_005f_005fenv_005flock-28"></a><a name="index-g_t_005f_005fenv_005funlock-29"></a><strong>Synopsis</strong> 40<pre class="example"> #include <envlock.h> 41 void __env_lock (struct _reent *<var>reent</var>); 42 void __env_unlock (struct _reent *<var>reent</var>); 43 44</pre> 45 <p><strong>Description</strong><br> 46The <code>setenv</code> family of routines call these functions when they need to 47modify the environ variable. The version of these routines supplied in the 48library use the lock API defined in sys/lock.h. If multiple threads of 49execution can call <code>setenv</code>, or if <code>setenv</code> can be called reentrantly, 50then you need to define your own versions of these functions in order to 51safely lock the memory pool during a call. If you do not, the memory pool 52may become corrupted. 53 54 <p>A call to <code>setenv</code> may call <code>__env_lock</code> recursively; that is, 55the sequence of calls may go <code>__env_lock</code>, <code>__env_lock</code>, 56<code>__env_unlock</code>, <code>__env_unlock</code>. Any implementation of these 57routines must be careful to avoid causing a thread to wait for a lock 58that it already holds. 59 60 <p><br> 61 62 </body></html> 63 64