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

Submitted by Cyrill Gorcunov on April 20, 2016, 4:09 p.m.

Details

Message ID 1461168547-10802-2-git-send-email-gorcunov@virtuozzo.com
State Rejected
Series "criu: restore -- Wait for userns completion"
Headers show

Patch hide | download patch | download mbox

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__ */

Comments

Andrey Vagin April 20, 2016, 6:02 p.m.
On Wed, Apr 20, 2016 at 07:09:06PM +0300, Cyrill Gorcunov wrote:
> Suitable for one-shot actions.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@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

Why is it not typedef?

> +
> +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);

I think we have to return wether it was compeleted of aborted
> +}
> +
>  #endif /* __CR_LOCK_H__ */
> -- 
> 2.5.5
>
Kirill Gorkunov April 20, 2016, 6:10 p.m.
On Wed, Apr 20, 2016 at 11:02:23AM -0700, Andrey Vagin wrote:
> >  
> > +#define completion_t futex_t
> 
> Why is it not typedef?

Dunno, just typed this way. Can update if you prefer.

> > +static inline void wait_for_completion(completion_t *c)
> > +{
> > +	futex_wait_until(c, 1);
> 
> I think we have to return wether it was compeleted of aborted

OK, will do.