From: Frank Mori Hess Date: Wed, 9 Feb 2005 01:53:23 +0000 (+0000) Subject: patch from Ian Abbott : X-Git-Tag: r0_7_70~52 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0b51c026c80bddccbbbfd01c886c016ce52c72b0;p=comedi.git patch from Ian Abbott : This patch adds compatibility code for the 'wait_event()' macro in linux/sched.h for kernels prior to 2.2.3. The actual implementation in this patch has been taken from 2.2.14. --- diff --git a/include/linux/sched.h b/include/linux/sched.h index 65631334..82bd7223 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -11,6 +11,62 @@ #define signal_pending(x) (((x)->signal) & (~(x)->blocked)) #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,2,3) +#define __wait_event(wq, condition) \ +do { \ + struct wait_queue __wait; \ + \ + __wait.task = current; \ + add_wait_queue(&wq, &__wait); \ + for (;;) { \ + current->state = TASK_UNINTERRUPTIBLE; \ + mb(); \ + if (condition) \ + break; \ + schedule(); \ + } \ + current->state = TASK_RUNNING; \ + remove_wait_queue(&wq, &__wait); \ +} while (0) + +#define wait_event(wq, condition) \ +do { \ + if (condition) \ + break; \ + __wait_event(wq, condition); \ +} while (0) + +#define __wait_event_interruptible(wq, condition, ret) \ +do { \ + struct wait_queue __wait; \ + \ + __wait.task = current; \ + add_wait_queue(&wq, &__wait); \ + for (;;) { \ + current->state = TASK_INTERRUPTIBLE; \ + mb(); \ + if (condition) \ + break; \ + if (!signal_pending(current)) { \ + schedule(); \ + continue; \ + } \ + ret = -ERESTARTSYS; \ + break; \ + } \ + current->state = TASK_RUNNING; \ + remove_wait_queue(&wq, &__wait); \ +} while (0) + +#define wait_event_interruptible(wq, condition) \ +({ \ + int __ret = 0; \ + if (!(condition)) \ + __wait_event_interruptible(wq, condition, __ret); \ + __ret; \ +}) +#endif + #include_next #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20)