[PATCH v2 1/2] Add static mutex initializer.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This prepares for the next patch.

The bad is we have no way to check the return value for
CreateMutex when it is used as a static initializer.
---
 src/util/threads-pthread.h |    5 +++++
 src/util/threads-win32.h   |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/util/threads-pthread.h b/src/util/threads-pthread.h
index b25d0c2..ff50253 100644
--- a/src/util/threads-pthread.h
+++ b/src/util/threads-pthread.h
@@ -23,6 +23,11 @@
 
 #include <pthread.h>
 
+#define VIR_MUTEX_INITIALIZER           \
+{                                       \
+    .lock = PTHREAD_MUTEX_INITIALIZER   \
+}
+
 struct virMutex {
     pthread_mutex_t lock;
 };
diff --git a/src/util/threads-win32.h b/src/util/threads-win32.h
index bb7c455..cfadbe4 100644
--- a/src/util/threads-win32.h
+++ b/src/util/threads-win32.h
@@ -23,6 +23,11 @@
 
 #include <windows.h>
 
+#define VIR_MUTEX_INITIALIZER                    \
+{                                                \
+    .lock = CreateMutex(NULL, FALSE, NULL)       \
+}
+
 struct virMutex {
     HANDLE lock;
 };
-- 
1.7.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]