Coverage Report

Created: 2017-10-25 09:10

/root/src/xen/xen/include/xen/wait.h
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 * wait.h
3
 * 
4
 * Sleep in hypervisor context for some event to occur.
5
 * 
6
 * Copyright (c) 2010, Keir Fraser <keir@xen.org>
7
 */
8
9
#ifndef __XEN_WAIT_H__
10
#define __XEN_WAIT_H__
11
12
#include <xen/types.h>
13
#include <xen/list.h>
14
#include <xen/spinlock.h>
15
16
struct waitqueue_head {
17
    spinlock_t lock;
18
    struct list_head list;
19
};
20
21
/* Statically define and initialise a waitqueue. */
22
#define DEFINE_WAITQUEUE_HEAD(name)             \
23
    struct waitqueue_head name = {              \
24
        .lock = SPIN_LOCK_UNLOCKED,             \
25
        .list = LIST_HEAD_INIT((name).list)     \
26
    }
27
28
/* Dynamically initialise/destroy a waitqueue. */
29
void init_waitqueue_head(struct waitqueue_head *wq);
30
void destroy_waitqueue_head(struct waitqueue_head *wq);
31
32
/* Wake VCPU(s) waiting on specified waitqueue. */
33
void wake_up_nr(struct waitqueue_head *wq, unsigned int nr);
34
void wake_up_one(struct waitqueue_head *wq);
35
void wake_up_all(struct waitqueue_head *wq);
36
37
/* Wait on specified waitqueue until @condition is true. */
38
0
#define wait_event(wq, condition)               \
39
0
do {                                            \
40
0
    if ( condition )                            \
41
0
        break;                                  \
42
0
    for ( ; ; ) {                               \
43
0
        prepare_to_wait(&wq);                   \
44
0
        if ( condition )                        \
45
0
            break;                              \
46
0
        wait();                                 \
47
0
    }                                           \
48
0
    finish_wait(&wq);                           \
49
0
} while (0)
50
51
/* Private functions. */
52
int init_waitqueue_vcpu(struct vcpu *v);
53
void destroy_waitqueue_vcpu(struct vcpu *v);
54
void prepare_to_wait(struct waitqueue_head *wq);
55
void wait(void);
56
void finish_wait(struct waitqueue_head *wq);
57
void check_wakeup_from_wait(void);
58
59
#endif /* __XEN_WAIT_H__ */