Changeset 6278 in vbox for trunk/src/VBox/Additions/linux
- Timestamp:
- Jan 8, 2008 2:11:28 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27128
- Location:
- trunk/src/VBox/Additions/linux/module
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/module/vboxmod.c
r6277 r6278 37 37 MODULE_VERSION(VBOX_VERSION_STRING " (interface " xstr(VMMDEV_VERSION) ")"); 38 38 #endif 39 40 /*****************************************************************************41 * Macros *42 *****************************************************************************/43 44 /* We need to define these ones here as they only exist in kernels 2.6 and up */45 46 #define __vbox_wait_event_interruptible_timeout(wq, condition, timeout, ret) \47 do { \48 int __ret = 0; \49 if (!(condition)) { \50 wait_queue_t __wait; \51 unsigned long expire; \52 init_waitqueue_entry(&__wait, current); \53 \54 expire = timeout + jiffies; \55 add_wait_queue(&wq, &__wait); \56 for (;;) { \57 set_current_state(TASK_INTERRUPTIBLE); \58 if (condition) \59 break; \60 if (jiffies > expire) { \61 ret = jiffies - expire; \62 break; \63 } \64 if (!signal_pending(current)) { \65 schedule_timeout(timeout); \66 continue; \67 } \68 ret = -ERESTARTSYS; \69 break; \70 } \71 current->state = TASK_RUNNING; \72 remove_wait_queue(&wq, &__wait); \73 } \74 } while (0)75 76 /*77 retval == 0; condition met; we're good.78 retval < 0; interrupted by signal.79 retval > 0; timed out.80 */81 #define vbox_wait_event_interruptible_timeout(wq, condition, timeout) \82 ({ \83 int __ret = 0; \84 if (!(condition)) \85 __vbox_wait_event_interruptible_timeout(wq, condition, \86 timeout, __ret); \87 __ret; \88 })89 90 39 91 40 /* This is called by our assert macros to find out whether we want … … 248 197 249 198 static void 250 vboxadd_wait_for_event (VBoxGuestWaitEventInfo * 199 vboxadd_wait_for_event (VBoxGuestWaitEventInfo *info) 251 200 { 252 201 long timeleft; … … 255 204 256 205 info->u32Result = VBOXGUEST_WAITEVENT_OK; 257 timeleft = vbox_wait_event_interruptible_timeout 258 (vboxDev->eventq, 259 (vboxDev->u32Events & in_mask) 260 || (vboxDev->u32GuestInterruptions != cInterruptions), 261 msecs_to_jiffies (info->u32TimeoutIn)); 262 if (vboxDev->u32GuestInterruptions != cInterruptions) { 263 info->u32Result = VBOXGUEST_WAITEVENT_INTERRUPTED; 264 } 265 if (timeleft < 0) { 266 info->u32Result = VBOXGUEST_WAITEVENT_INTERRUPTED; 267 } 268 if (timeleft == 0) { 269 info->u32Result = VBOXGUEST_WAITEVENT_TIMEOUT; 206 if (0 != info->u32TimeoutIn) { 207 timeleft = wait_event_interruptible_timeout 208 (vboxDev->eventq, 209 (vboxDev->u32Events & in_mask) 210 || (vboxDev->u32GuestInterruptions != cInterruptions), 211 msecs_to_jiffies (info->u32TimeoutIn) 212 ); 213 if (vboxDev->u32GuestInterruptions != cInterruptions) { 214 info->u32Result = VBOXGUEST_WAITEVENT_INTERRUPTED; 215 } 216 if (timeleft < 0) { 217 info->u32Result = VBOXGUEST_WAITEVENT_INTERRUPTED; 218 } 219 if (timeleft == 0) { 220 info->u32Result = VBOXGUEST_WAITEVENT_TIMEOUT; 221 } 222 } 223 else { 224 if (wait_event_interruptible(vboxDev->eventq, 225 (vboxDev->u32Events & in_mask) 226 || (vboxDev->u32GuestInterruptions != cInterruptions) 227 ) 228 ) { 229 info->u32Result = VBOXGUEST_WAITEVENT_INTERRUPTED; 230 } 270 231 } 271 232 info->u32EventFlagsOut = vboxDev->u32Events & in_mask; … … 437 398 { 438 399 VMMDevHGCMRequestHeader *reqHGCM = (VMMDevHGCMRequestHeader*)reqFull; 439 wait_event (vboxDev->eventq, reqHGCM->fu32Flags & VBOX_HGCM_REQ_DONE);400 wait_event_interruptible (vboxDev->eventq, reqHGCM->fu32Flags & VBOX_HGCM_REQ_DONE); 440 401 rc = reqFull->rc; 441 402 } … … 927 888 Log(("Successfully loaded VirtualBox device version " 928 889 VBOX_VERSION_STRING " (interface " xstr(VMMDEV_VERSION) ")\n")); 890 929 891 /* successful return */ 930 892 PCI_DEV_PUT(pcidev); -
trunk/src/VBox/Additions/linux/module/waitcompat.h
r5753 r6278 29 29 #endif 30 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 */
Note:
See TracChangeset
for help on using the changeset viewer.