Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > media > main-release > by-pkgid > 926d2d1e3111287cee1b0a4fad4fb4f6 > files > 134

lib64dbus-1_3-devel-0.92-6mdv2007.0.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>dbus-threads.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>dbus-threads.c</h1><div class="fragment"><pre>00001 <font class="comment">/* -*- mode: C; c-file-style: "gnu" -*- */</font>
00002 <font class="comment">/* dbus-threads.h  D-BUS threads handling</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * Copyright (C) 2002, 2003 Red Hat Inc.</font>
00005 <font class="comment"> *</font>
00006 <font class="comment"> * Licensed under the Academic Free License version 2.0</font>
00007 <font class="comment"> * </font>
00008 <font class="comment"> * This program is free software; you can redistribute it and/or modify</font>
00009 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00010 <font class="comment"> * the Free Software Foundation; either version 2 of the License, or</font>
00011 <font class="comment"> * (at your option) any later version.</font>
00012 <font class="comment"> *</font>
00013 <font class="comment"> * This program is distributed in the hope that it will be useful,</font>
00014 <font class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00015 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</font>
00016 <font class="comment"> * GNU General Public License for more details.</font>
00017 <font class="comment"> * </font>
00018 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00019 <font class="comment"> * along with this program; if not, write to the Free Software</font>
00020 <font class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</font>
00021 <font class="comment"> *</font>
00022 <font class="comment"> */</font>
00023 <font class="preprocessor">#include "dbus-threads.h"</font>
00024 <font class="preprocessor">#include "dbus-internals.h"</font>
00025 
00026 <font class="keyword">static</font> <a class="code" href="structDBusThreadFunctions.html">DBusThreadFunctions</a> thread_functions =
00027 {
00028   0,
00029   NULL, NULL, NULL, NULL,
00030   NULL, NULL, NULL, NULL, NULL,
00031 
00032   NULL, NULL, NULL, NULL,
00033   NULL, NULL, NULL, NULL
00034 };
00035 <font class="keyword">static</font> <font class="keywordtype">int</font> thread_init_generation = 0;
00036 
00038 <font class="preprocessor">#define _DBUS_DUMMY_MUTEX ((DBusMutex*)0xABCDEF)</font>
00039 <font class="preprocessor"></font>
00041 <font class="preprocessor">#define _DBUS_DUMMY_CONDVAR ((DBusCondVar*)0xABCDEF2)</font>
00042 <font class="preprocessor"></font>
00061 DBusMutex*
<a name="l00062"></a><a class="code" href="group__DBusThreads.html#a0">00062</a> dbus_mutex_new (<font class="keywordtype">void</font>)
00063 {
00064   <font class="keywordflow">if</font> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#m1">mutex_new</a>)
00065     <font class="keywordflow">return</font> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m1">mutex_new</a>) ();
00066   <font class="keywordflow">else</font>
00067     <font class="keywordflow">return</font> _DBUS_DUMMY_MUTEX;
00068 }
00069 
00074 <font class="keywordtype">void</font>
<a name="l00075"></a><a class="code" href="group__DBusThreads.html#a1">00075</a> dbus_mutex_free (DBusMutex *mutex)
00076 {
00077   <font class="keywordflow">if</font> (mutex &amp;&amp; thread_functions.<a class="code" href="structDBusThreadFunctions.html#m2">mutex_free</a>)
00078     (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m2">mutex_free</a>) (mutex);
00079 }
00080 
00087 dbus_bool_t
<a name="l00088"></a><a class="code" href="group__DBusThreads.html#a2">00088</a> dbus_mutex_lock (DBusMutex *mutex)
00089 {
00090   <font class="keywordflow">if</font> (mutex &amp;&amp; thread_functions.<a class="code" href="structDBusThreadFunctions.html#m3">mutex_lock</a>)
00091     <font class="keywordflow">return</font> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m3">mutex_lock</a>) (mutex);
00092   <font class="keywordflow">else</font>
00093     <font class="keywordflow">return</font> TRUE;
00094 }
00095 
00101 dbus_bool_t
<a name="l00102"></a><a class="code" href="group__DBusThreads.html#a3">00102</a> dbus_mutex_unlock (DBusMutex *mutex)
00103 {
00104   <font class="keywordflow">if</font> (mutex &amp;&amp; thread_functions.<a class="code" href="structDBusThreadFunctions.html#m4">mutex_unlock</a>)
00105     <font class="keywordflow">return</font> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m4">mutex_unlock</a>) (mutex);
00106   <font class="keywordflow">else</font>
00107     <font class="keywordflow">return</font> TRUE;
00108 }
00109 
00118 DBusCondVar *
<a name="l00119"></a><a class="code" href="group__DBusThreads.html#a4">00119</a> dbus_condvar_new (<font class="keywordtype">void</font>)
00120 {
00121   <font class="keywordflow">if</font> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#m5">condvar_new</a>)
00122     <font class="keywordflow">return</font> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m5">condvar_new</a>) ();
00123   <font class="keywordflow">else</font>
00124     <font class="keywordflow">return</font> _DBUS_DUMMY_CONDVAR;
00125 }
00126 
00131 <font class="keywordtype">void</font>
<a name="l00132"></a><a class="code" href="group__DBusThreads.html#a5">00132</a> dbus_condvar_free (DBusCondVar *cond)
00133 {
00134   <font class="keywordflow">if</font> (cond &amp;&amp; thread_functions.<a class="code" href="structDBusThreadFunctions.html#m6">condvar_free</a>)
00135     (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m6">condvar_free</a>) (cond);
00136 }
00137 
00144 <font class="keywordtype">void</font>
<a name="l00145"></a><a class="code" href="group__DBusThreads.html#a6">00145</a> dbus_condvar_wait (DBusCondVar *cond,
00146                    DBusMutex   *mutex)
00147 {
00148   <font class="keywordflow">if</font> (cond &amp;&amp; mutex &amp;&amp; thread_functions.<a class="code" href="structDBusThreadFunctions.html#m7">condvar_wait</a>)
00149     (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m7">condvar_wait</a>) (cond, mutex);
00150 }
00151 
00164 dbus_bool_t
<a name="l00165"></a><a class="code" href="group__DBusThreads.html#a7">00165</a> dbus_condvar_wait_timeout (DBusCondVar               *cond,
00166                            DBusMutex                 *mutex,
00167                            <font class="keywordtype">int</font>                        timeout_milliseconds)
00168 {
00169   <font class="keywordflow">if</font> (cond &amp;&amp; mutex &amp;&amp; thread_functions.<a class="code" href="structDBusThreadFunctions.html#m7">condvar_wait</a>)
00170     <font class="keywordflow">return</font> (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m8">condvar_wait_timeout</a>) (cond, mutex, timeout_milliseconds);
00171   <font class="keywordflow">else</font>
00172     <font class="keywordflow">return</font> TRUE;
00173 }
00174 
00180 <font class="keywordtype">void</font>
<a name="l00181"></a><a class="code" href="group__DBusThreads.html#a8">00181</a> dbus_condvar_wake_one (DBusCondVar *cond)
00182 {
00183   <font class="keywordflow">if</font> (cond &amp;&amp; thread_functions.<a class="code" href="structDBusThreadFunctions.html#m9">condvar_wake_one</a>)
00184     (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m9">condvar_wake_one</a>) (cond);
00185 }
00186 
00192 <font class="keywordtype">void</font>
<a name="l00193"></a><a class="code" href="group__DBusThreads.html#a9">00193</a> dbus_condvar_wake_all (DBusCondVar *cond)
00194 {
00195   <font class="keywordflow">if</font> (cond &amp;&amp; thread_functions.<a class="code" href="structDBusThreadFunctions.html#m10">condvar_wake_all</a>)
00196     (* thread_functions.<a class="code" href="structDBusThreadFunctions.html#m10">condvar_wake_all</a>) (cond);
00197 }
00198 
00199 <font class="keyword">static</font> <font class="keywordtype">void</font>
00200 shutdown_global_locks (<font class="keywordtype">void</font> *data)
00201 {
00202   DBusMutex ***locks = data;
00203   <font class="keywordtype">int</font> i;
00204 
00205   i = 0;
00206   <font class="keywordflow">while</font> (i &lt; _DBUS_N_GLOBAL_LOCKS)
00207     {
00208       dbus_mutex_free (*(locks[i]));
00209       *(locks[i]) = NULL;
00210       ++i;
00211     }
00212   
00213   dbus_free (locks);
00214 }
00215 
00216 <font class="keyword">static</font> dbus_bool_t
00217 init_global_locks (<font class="keywordtype">void</font>)
00218 {
00219   <font class="keywordtype">int</font> i;
00220   DBusMutex ***dynamic_global_locks;
00221   
00222   DBusMutex **global_locks[] = {
00223 <font class="preprocessor">#define LOCK_ADDR(name) (&amp; _dbus_lock_##name)</font>
00224 <font class="preprocessor"></font>    LOCK_ADDR (list),
00225     LOCK_ADDR (connection_slots),
00226     LOCK_ADDR (pending_call_slots),
00227     LOCK_ADDR (server_slots),
00228     LOCK_ADDR (message_slots),
00229     LOCK_ADDR (atomic),
00230     LOCK_ADDR (bus),
00231     LOCK_ADDR (shutdown_funcs),
00232     LOCK_ADDR (system_users)
00233 <font class="preprocessor">#undef LOCK_ADDR</font>
00234 <font class="preprocessor"></font>  };
00235 
00236   _dbus_assert (_DBUS_N_ELEMENTS (global_locks) ==
00237                 _DBUS_N_GLOBAL_LOCKS);
00238 
00239   i = 0;
00240   
00241   dynamic_global_locks = dbus_new (DBusMutex**, _DBUS_N_GLOBAL_LOCKS);
00242   <font class="keywordflow">if</font> (dynamic_global_locks == NULL)
00243     <font class="keywordflow">goto</font> failed;
00244   
00245   <font class="keywordflow">while</font> (i &lt; _DBUS_N_ELEMENTS (global_locks))
00246     {
00247       *global_locks[i] = dbus_mutex_new ();
00248       
00249       <font class="keywordflow">if</font> (*global_locks[i] == NULL)
00250         <font class="keywordflow">goto</font> failed;
00251 
00252       dynamic_global_locks[i] = global_locks[i];
00253 
00254       ++i;
00255     }
00256   
00257   <font class="keywordflow">if</font> (!_dbus_register_shutdown_func (shutdown_global_locks,
00258                                      dynamic_global_locks))
00259     <font class="keywordflow">goto</font> failed;
00260   
00261   <font class="keywordflow">return</font> TRUE;
00262 
00263  failed:
00264   dbus_free (dynamic_global_locks);
00265                                      
00266   <font class="keywordflow">for</font> (i = i - 1; i &gt;= 0; i--)
00267     {
00268       dbus_mutex_free (*global_locks[i]);
00269       *global_locks[i] = NULL;
00270     }
00271   <font class="keywordflow">return</font> FALSE;
00272 }
00273 
00274 
00290 dbus_bool_t
<a name="l00291"></a><a class="code" href="group__DBusThreads.html#a12">00291</a> dbus_threads_init (<font class="keyword">const</font> <a class="code" href="structDBusThreadFunctions.html">DBusThreadFunctions</a> *functions)
00292 {
00293   _dbus_assert (functions != NULL);
00294 
00295   <font class="comment">/* these base functions are required. Future additions to</font>
00296 <font class="comment">   * DBusThreadFunctions may be optional.</font>
00297 <font class="comment">   */</font>
00298   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK);
00299   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK);
00300   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK);
00301   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK);
00302   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK);
00303   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK);
00304   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK);
00305   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK);
00306   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK);
00307   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK);
00308   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m1">mutex_new</a> != NULL);
00309   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m2">mutex_free</a> != NULL);
00310   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m3">mutex_lock</a> != NULL);
00311   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m4">mutex_unlock</a> != NULL);
00312   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m5">condvar_new</a> != NULL);
00313   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m6">condvar_free</a> != NULL);
00314   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m7">condvar_wait</a> != NULL);
00315   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m8">condvar_wait_timeout</a> != NULL);
00316   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m9">condvar_wake_one</a> != NULL);
00317   _dbus_assert (functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m10">condvar_wake_all</a> != NULL);
00318 
00319   <font class="comment">/* Check that all bits in the mask actually are valid mask bits.</font>
00320 <font class="comment">   * ensures people won't write code that breaks when we add</font>
00321 <font class="comment">   * new bits.</font>
00322 <font class="comment">   */</font>
00323   _dbus_assert ((functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp; ~DBUS_THREAD_FUNCTIONS_ALL_MASK) == 0);
00324 
00325   <font class="keywordflow">if</font> (thread_init_generation != _dbus_current_generation)
00326     thread_functions.<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> = 0; <font class="comment">/* allow re-init in new generation */</font>
00327   
00328   <font class="keywordflow">if</font> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> != 0)
00329     {
00330       <font class="comment">/* Silently allow multiple init if the functions are the same ones.</font>
00331 <font class="comment">       * Well, we only bother checking two of them, just out of laziness.</font>
00332 <font class="comment">       */</font>
00333       <font class="keywordflow">if</font> (thread_functions.<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> == functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> &amp;&amp;
00334           thread_functions.<a class="code" href="structDBusThreadFunctions.html#m1">mutex_new</a> == functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m1">mutex_new</a> &amp;&amp;
00335           thread_functions.<a class="code" href="structDBusThreadFunctions.html#m5">condvar_new</a> == functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m5">condvar_new</a>)
00336         {
00337           <font class="keywordflow">return</font> TRUE;
00338         }
00339       <font class="keywordflow">else</font>
00340         {
00341           _dbus_warn (<font class="stringliteral">"dbus_threads_init() called twice with two different sets of functions\n"</font>);
00342           <font class="keywordflow">return</font> FALSE;
00343         }
00344     }
00345   
00346   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m1">mutex_new</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m1">mutex_new</a>;
00347   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m2">mutex_free</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m2">mutex_free</a>;
00348   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m3">mutex_lock</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m3">mutex_lock</a>;
00349   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m4">mutex_unlock</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m4">mutex_unlock</a>;
00350   
00351   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m5">condvar_new</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m5">condvar_new</a>;
00352   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m6">condvar_free</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m6">condvar_free</a>;
00353   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m7">condvar_wait</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m7">condvar_wait</a>;
00354   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m8">condvar_wait_timeout</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m8">condvar_wait_timeout</a>;
00355   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m9">condvar_wake_one</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m9">condvar_wake_one</a>;
00356   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m10">condvar_wake_all</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m10">condvar_wake_all</a>;
00357   
00358   thread_functions.<a class="code" href="structDBusThreadFunctions.html#m0">mask</a> = functions-&gt;<a class="code" href="structDBusThreadFunctions.html#m0">mask</a>;
00359 
00360   <font class="keywordflow">if</font> (!init_global_locks ())
00361     <font class="keywordflow">return</font> FALSE;
00362 
00363   thread_init_generation = _dbus_current_generation;
00364   
00365   <font class="keywordflow">return</font> TRUE;
00366 }
00367 
00370 <font class="preprocessor">#ifdef DBUS_BUILD_TESTS</font>
00371 <font class="preprocessor"></font>
00372 <font class="keyword">typedef</font> <font class="keyword">struct </font><a class="code" href="structDBusFakeMutex.html">DBusFakeMutex</a> DBusFakeMutex;
<a name="l00374"></a><a class="code" href="structDBusFakeMutex.html">00374</a> <font class="keyword">struct </font>DBusFakeMutex
00375 {
<a name="l00376"></a><a class="code" href="structDBusFakeMutex.html#m0">00376</a>   dbus_bool_t <a class="code" href="structDBusFakeMutex.html#m0">locked</a>; 
00377 };      
00378 
00379 <font class="keyword">static</font> DBusMutex *  dbus_fake_mutex_new            (<font class="keywordtype">void</font>);
00380 <font class="keyword">static</font> <font class="keywordtype">void</font>         dbus_fake_mutex_free           (DBusMutex   *mutex);
00381 <font class="keyword">static</font> dbus_bool_t  dbus_fake_mutex_lock           (DBusMutex   *mutex);
00382 <font class="keyword">static</font> dbus_bool_t  dbus_fake_mutex_unlock         (DBusMutex   *mutex);
00383 <font class="keyword">static</font> DBusCondVar* dbus_fake_condvar_new          (<font class="keywordtype">void</font>);
00384 <font class="keyword">static</font> <font class="keywordtype">void</font>         dbus_fake_condvar_free         (DBusCondVar *cond);
00385 <font class="keyword">static</font> <font class="keywordtype">void</font>         dbus_fake_condvar_wait         (DBusCondVar *cond,
00386                                                     DBusMutex   *mutex);
00387 <font class="keyword">static</font> dbus_bool_t  dbus_fake_condvar_wait_timeout (DBusCondVar *cond,
00388                                                     DBusMutex   *mutex,
00389                                                     <font class="keywordtype">int</font>          timeout_msec);
00390 <font class="keyword">static</font> <font class="keywordtype">void</font>         dbus_fake_condvar_wake_one     (DBusCondVar *cond);
00391 <font class="keyword">static</font> <font class="keywordtype">void</font>         dbus_fake_condvar_wake_all     (DBusCondVar *cond);
00392 
00393 
00394 <font class="keyword">static</font> <font class="keyword">const</font> <a class="code" href="structDBusThreadFunctions.html">DBusThreadFunctions</a> fake_functions =
00395 {
00396   DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK |
00397   DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK |
00398   DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK |
00399   DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK |
00400   DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK |
00401   DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK |
00402   DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK |
00403   DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK |
00404   DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK|
00405   DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK,
00406   dbus_fake_mutex_new,
00407   dbus_fake_mutex_free,
00408   dbus_fake_mutex_lock,
00409   dbus_fake_mutex_unlock,
00410   dbus_fake_condvar_new,
00411   dbus_fake_condvar_free,
00412   dbus_fake_condvar_wait,
00413   dbus_fake_condvar_wait_timeout,
00414   dbus_fake_condvar_wake_one,
00415   dbus_fake_condvar_wake_all
00416 };
00417 
00418 <font class="keyword">static</font> DBusMutex *
00419 dbus_fake_mutex_new (<font class="keywordtype">void</font>)
00420 {
00421   DBusFakeMutex *mutex;
00422 
00423   mutex = dbus_new0 (DBusFakeMutex, 1);
00424 
00425   <font class="keywordflow">return</font> (DBusMutex *)mutex;
00426 }
00427 
00428 <font class="keyword">static</font> <font class="keywordtype">void</font>
00429 dbus_fake_mutex_free (DBusMutex *mutex)
00430 {
00431   DBusFakeMutex *fake = (DBusFakeMutex*) mutex;
00432 
00433   _dbus_assert (!fake-&gt;<a class="code" href="structDBusFakeMutex.html#m0">locked</a>);
00434   
00435   dbus_free (fake);
00436 }
00437 
00438 <font class="keyword">static</font> dbus_bool_t
00439 dbus_fake_mutex_lock (DBusMutex *mutex)
00440 {
00441   DBusFakeMutex *fake = (DBusFakeMutex*) mutex;
00442 
00443   _dbus_assert (!fake-&gt;<a class="code" href="structDBusFakeMutex.html#m0">locked</a>);
00444 
00445   fake-&gt;<a class="code" href="structDBusFakeMutex.html#m0">locked</a> = TRUE;
00446   
00447   <font class="keywordflow">return</font> TRUE;
00448 }
00449 
00450 <font class="keyword">static</font> dbus_bool_t
00451 dbus_fake_mutex_unlock (DBusMutex *mutex)
00452 {
00453   DBusFakeMutex *fake = (DBusFakeMutex*) mutex;
00454 
00455   _dbus_assert (fake-&gt;<a class="code" href="structDBusFakeMutex.html#m0">locked</a>);
00456 
00457   fake-&gt;<a class="code" href="structDBusFakeMutex.html#m0">locked</a> = FALSE;
00458   
00459   <font class="keywordflow">return</font> TRUE;
00460 }
00461 
00462 <font class="keyword">static</font> DBusCondVar*
00463 dbus_fake_condvar_new (<font class="keywordtype">void</font>)
00464 {
00465   <font class="keywordflow">return</font> (DBusCondVar*) _dbus_strdup (<font class="stringliteral">"FakeCondvar"</font>);
00466 }
00467 
00468 <font class="keyword">static</font> <font class="keywordtype">void</font>
00469 dbus_fake_condvar_free (DBusCondVar *cond)
00470 {
00471   dbus_free (cond);
00472 }
00473 
00474 <font class="keyword">static</font> <font class="keywordtype">void</font>
00475 dbus_fake_condvar_wait (DBusCondVar *cond,
00476                         DBusMutex   *mutex)
00477 {
00478   
00479 }
00480 
00481 <font class="keyword">static</font> dbus_bool_t
00482 dbus_fake_condvar_wait_timeout (DBusCondVar *cond,
00483                                 DBusMutex   *mutex,
00484                                 <font class="keywordtype">int</font>         timeout_msec)
00485 {
00486   <font class="keywordflow">return</font> TRUE;
00487 }
00488 
00489 <font class="keyword">static</font> <font class="keywordtype">void</font>
00490 dbus_fake_condvar_wake_one (DBusCondVar *cond)
00491 {
00492 
00493 }
00494 
00495 <font class="keyword">static</font> <font class="keywordtype">void</font>
00496 dbus_fake_condvar_wake_all (DBusCondVar *cond)
00497 {
00498 
00499 }
00500 
00501 dbus_bool_t
00502 _dbus_threads_init_debug (<font class="keywordtype">void</font>)
00503 {
00504   <font class="keywordflow">return</font> dbus_threads_init (&amp;fake_functions);
00505 }
00506 
00507 <font class="preprocessor">#endif </font><font class="comment">/* DBUS_BUILD_TESTS */</font>
</pre></div><hr><address align="right"><small>Generated on Wed Jun 9 05:01:27 2004 for D-BUS by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>