Make the thread functions a bit easier to use
[ira/wip.git] / lib / util / smb_threads_internal.h
index 038c584b608c151c8d78ee40a038445edcf838b2..afd7559f3b001a536eb8ca977375f20c59f1e130 100644 (file)
                }; \
        } while (0)
 
-#define SMB_THREAD_LOCK(plock, type) \
-       (global_tfp ? global_tfp->lock_mutex((plock), (type), __location__) : 0)
+#define SMB_THREAD_LOCK_INTERNAL(plock, type, location) \
+       (global_tfp ? global_tfp->lock_mutex((plock), (type), location) : 0)
+
+#define SMB_THREAD_LOCK(plock) \
+        SMB_THREAD_LOCK_INTERNAL(plock, SMB_THREAD_LOCK, __location__)
+
+#define SMB_THREAD_UNLOCK(plock) \
+        SMB_THREAD_LOCK_INTERNAL(plock, SMB_THREAD_UNLOCK, __location__)
 
 #define SMB_THREAD_ONCE(ponce, init_fn, pdata)                  \
         (global_tfp                                             \
          ? (! *(ponce)                                          \
             ? smb_thread_once((ponce), (init_fn), (pdata))      \
             : 0)                                                \
-         : ((init_fn(pdata)), 0))
+         : ((init_fn(pdata)), *(ponce) = true, 1))
 
 #define SMB_THREAD_CREATE_TLS(keyname, key) \
        (global_tfp ? global_tfp->create_tls((keyname), &(key), __location__) : 0)