revert-ubik-changes-20080405
[openafs.git] / src / util / pthread_glock.c
index 240be4e..e6e6f78 100644 (file)
@@ -7,7 +7,12 @@
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
+#include <afsconfig.h>
 #include <afs/param.h>
+
+RCSID
+    ("$Header$");
+
 #if defined(AFS_NT40_ENV) && defined(AFS_PTHREAD_ENV)
 #define AFS_GRMUTEX_DECLSPEC __declspec(dllexport)
 #endif
 
 pthread_recursive_mutex_t grmutex;
 
-static int glock_init;
+static int glock_init = 0;
 static pthread_once_t glock_init_once = PTHREAD_ONCE_INIT;
 
-static void glock_init_func(void) {
-    pthread_mutex_init(&grmutex.mut, (const pthread_mutexattr_t *) 0);
+static void
+glock_init_func(void)
+{
+    pthread_mutex_init(&grmutex.mut, (const pthread_mutexattr_t *)0);
     grmutex.times_inside = 0;
     grmutex.owner = (pthread_t) 0;
     grmutex.locked = 0;
     glock_init = 1;
 }
 
-int pthread_recursive_mutex_lock(pthread_recursive_mutex_t *mut) {
-    int rc=0;
+int
+pthread_recursive_mutex_lock(pthread_recursive_mutex_t * mut)
+{
+    int rc = 0;
 
     (glock_init || pthread_once(&glock_init_once, glock_init_func));
 
     if (mut->locked) {
-       if (pthread_equal(mut->owner,pthread_self())) {
+       if (pthread_equal(mut->owner, pthread_self())) {
            mut->times_inside++;
            return rc;
        }
-    } 
+    }
     rc = pthread_mutex_lock(&mut->mut);
     if (rc == 0) {
        mut->times_inside = 1;
@@ -53,12 +62,14 @@ int pthread_recursive_mutex_lock(pthread_recursive_mutex_t *mut) {
     return rc;
 }
 
-int pthread_recursive_mutex_unlock(pthread_recursive_mutex_t *mut) {
-    int rc=0;
+int
+pthread_recursive_mutex_unlock(pthread_recursive_mutex_t * mut)
+{
+    int rc = 0;
 
     (glock_init || pthread_once(&glock_init_once, glock_init_func));
 
-    if ((mut->locked) && (pthread_equal(mut->owner,pthread_self()))) {
+    if ((mut->locked) && (pthread_equal(mut->owner, pthread_self()))) {
        mut->times_inside--;
        if (mut->times_inside == 0) {
            mut->locked = 0;