[CRIU] [PATCH 1/2] criu: lock -- Add completions

Cyrill Gorcunov gorcunov at gmail.com
Wed Apr 20 09:09:06 PDT 2016


Suitable for one-shot actions.

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
 criu/include/lock.h | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/criu/include/lock.h b/criu/include/lock.h
index 1678d10..fcc5ed8 100644
--- a/criu/include/lock.h
+++ b/criu/include/lock.h
@@ -154,4 +154,26 @@ static inline void mutex_unlock(mutex_t *m)
 	BUG_ON(sys_futex((u32 *)&m->raw.counter, FUTEX_WAKE, 1, NULL, NULL, 0) < 0);
 }
 
+#define completion_t futex_t
+
+static inline void init_completion(completion_t *c)
+{
+	futex_init(c);
+}
+
+static inline void complete(completion_t *c)
+{
+	futex_set_and_wake(c, 1);
+}
+
+static inline void abort_completion(completion_t *c)
+{
+	futex_abort_and_wake(c);
+}
+
+static inline void wait_for_completion(completion_t *c)
+{
+	futex_wait_until(c, 1);
+}
+
 #endif /* __CR_LOCK_H__ */
-- 
2.5.5



More information about the CRIU mailing list