Merged silc_1_0_branch to trunk.
[silc.git] / lib / silcutil / silcmutex.h
index ef02621ee07d19bb3346a9466edceb3ab2facfce..19b4863f61790e8be92b5f40b67cd27b880cc0e9 100644 (file)
@@ -1,42 +1,39 @@
-/****h* silcutil/silcmutex.h
- *
- * NAME
- *
- * silcmutex.h
- *
- * COPYRIGHT
- *
- * Author: Pekka Riikonen <priikone@silcnet.org>
- *
- * Copyright (C) 2001 Pekka Riikonen
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+/*
+
+  silcmutex.h
+
+  Author: Pekka Riikonen <priikone@silcnet.org>
+
+  Copyright (C) 2001 - 2005 Pekka Riikonen
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+*/
+
+/****h* silcutil/SILC Mutex Interface
  *
  * DESCRIPTION
  *
  * Interface for the SILC Mutex locking implementation. This is platform
- * independent mutual exclusion interface for applications that need 
+ * independent mutual exclusion interface for applications that need
  * concurrency control.
  *
- */
+ ***/
 
 #ifndef SILCMUTEX_H
 #define SILCMUTEX_H
 
-#ifdef SILC_THREADS
-
 /****s* silcutil/SilcMutexAPI/SilcMutex
  *
  * NAME
- * 
+ *
  *    typedef struct SilcMutexStruct *SilcMutex;
  *
  * DESCRIPTION
@@ -51,7 +48,7 @@ typedef struct SilcMutexStruct *SilcMutex;
 /****d* silcutil/SilcMutexAPI/SILC_MUTEX_DEFINE
  *
  * NAME
- * 
+ *
  *    #define SILC_MUTEX_DEFINE(name) ...
  *
  * DESCRIPTION
@@ -69,15 +66,17 @@ typedef struct SilcMutexStruct *SilcMutex;
  *
  * SYNOPSIS
  *
- *    SilcMutex silc_mutex_alloc(void);
+ *    bool silc_mutex_alloc(SilcMutex *mutex);
  *
  * DESCRIPTION
  *
  *    Allocates SILC Mutex object.  The mutex object must be allocated
  *    before it can be used.  It is freed by the silc_mutex_free function.
+ *    This returns TRUE and allocated mutex in to the `mutex' and FALSE
+ *    on error.
  *
  ***/
-SilcMutex silc_mutex_alloc(void);
+bool silc_mutex_alloc(SilcMutex *mutex);
 
 /****f* silcutil/SilcMutexAPI/silc_mutex_free
  *
@@ -87,7 +86,8 @@ SilcMutex silc_mutex_alloc(void);
  *
  * DESCRIPTION
  *
- *    Free SILC Mutex object and frees all allocated memory.
+ *    Free SILC Mutex object and frees all allocated memory.  If `mutex'
+ *    is NULL this function has no effect.
  *
  ***/
 void silc_mutex_free(SilcMutex mutex);
@@ -102,7 +102,8 @@ void silc_mutex_free(SilcMutex mutex);
  *
  *    Locks the mutex. If the mutex is locked by another thread the
  *    current thread will block until the other thread has issued
- *    silc_mutex_unlock for the mutex.
+ *    silc_mutex_unlock for the mutex.  If `mutex' is NULL this function
+ *    has no effect.
  *
  * NOTES
  *
@@ -122,7 +123,8 @@ void silc_mutex_lock(SilcMutex mutex);
  * DESCRIPTION
  *
  *    Unlocks the mutex and thus releases it for another thread that
- *    may be waiting for the lock.
+ *    may be waiting for the lock.  If `mutex' is NULL this function
+ *    has no effect.
  *
  * NOTES
  *
@@ -133,14 +135,4 @@ void silc_mutex_lock(SilcMutex mutex);
  ***/
 void silc_mutex_unlock(SilcMutex mutex);
 
-#else
-
-#define SILC_MUTEX_DEFINE(name)
-#define silc_mutex_alloc()
-#define silc_mutex_free(mutex)
-#define silc_mutex_lock(mutex)
-#define silc_mutex_unlock(mutex)
-
-#endif         /* SILC_THREADS */
-
 #endif