~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« back to all changes in this revision

Viewing changes to src/VBox/Additions/linux/module/waitcompat.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* copied from linux/wait.h */
2
 
 
3
 
#ifndef wait_event_timeout
4
 
#define wait_event_timeout(wq, condition, timeout)              \
5
 
({                                                              \
6
 
        long __ret = timeout;                                   \
7
 
        if (!(condition))                                       \
8
 
                __wait_event_timeout(wq, condition, __ret);     \
9
 
        __ret;                                                  \
10
 
 })
11
 
 
12
 
#define __wait_event_timeout(wq, condition, ret)                \
13
 
do {                                                            \
14
 
        wait_queue_t __wait;                                    \
15
 
        init_waitqueue_entry(&__wait, current);                 \
16
 
                                                                \
17
 
        add_wait_queue(&wq, &__wait);                           \
18
 
        for (;;) {                                              \
19
 
                set_current_state(TASK_UNINTERRUPTIBLE);        \
20
 
                if (condition)                                  \
21
 
                        break;                                  \
22
 
                ret = schedule_timeout(ret);                    \
23
 
                if (!ret)                                       \
24
 
                        break;                                  \
25
 
        }                                                       \
26
 
        current->state = TASK_RUNNING;                          \
27
 
        remove_wait_queue(&wq, &__wait);                        \
28
 
} while (0)
29
 
#endif
30
 
 
31
 
#ifndef wait_event_interruptible_timeout
32
 
 
33
 
/* We need to define these ones here as they only exist in kernels 2.6 and up */
34
 
 
35
 
#define __wait_event_interruptible_timeout(wq, condition, timeout, ret)   \
36
 
do {                                                                      \
37
 
        int __ret = 0;                                                    \
38
 
        if (!(condition)) {                                               \
39
 
          wait_queue_t __wait;                                            \
40
 
          unsigned long expire;                                           \
41
 
          init_waitqueue_entry(&__wait, current);                         \
42
 
                                                                          \
43
 
          expire = timeout + jiffies;                                     \
44
 
          add_wait_queue(&wq, &__wait);                                   \
45
 
          for (;;) {                                                      \
46
 
                  set_current_state(TASK_INTERRUPTIBLE);                  \
47
 
                  if (condition)                                          \
48
 
                          break;                                          \
49
 
                  if (jiffies > expire) {                                 \
50
 
                          ret = jiffies - expire;                         \
51
 
                          break;                                          \
52
 
                  }                                                       \
53
 
                  if (!signal_pending(current)) {                         \
54
 
                          schedule_timeout(timeout);                      \
55
 
                          continue;                                       \
56
 
                  }                                                       \
57
 
                  ret = -ERESTARTSYS;                                     \
58
 
                  break;                                                  \
59
 
          }                                                               \
60
 
          current->state = TASK_RUNNING;                                  \
61
 
          remove_wait_queue(&wq, &__wait);                                \
62
 
        }                                                                 \
63
 
} while (0)
64
 
 
65
 
/*
66
 
   retval == 0; condition met; we're good.
67
 
   retval < 0; interrupted by signal.
68
 
   retval > 0; timed out.
69
 
*/
70
 
#define wait_event_interruptible_timeout(wq, condition, timeout)        \
71
 
({                                                                      \
72
 
        int __ret = 0;                                                  \
73
 
        if (!(condition))                                               \
74
 
                __wait_event_interruptible_timeout(wq, condition,       \
75
 
                                                timeout, __ret);        \
76
 
        __ret;                                                          \
77
 
})
78
 
 
79
 
#endif  /* wait_event_interruptible_timeout not defined */