lkml.org 
[lkml]   [1999]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] sleep_on() fixes, 2.2.3-1
On Sat, 6 Mar 1999, Ingo Molnar wrote:

>
>On Sat, 6 Mar 1999, Andrea Arcangeli wrote:
>
>> >+#define __wait_event_interruptible(wq, condition) \
>>
>> Here I think we could add a third param to the macro, that will be the
>> retval in the interrupted case. It's zero cost and looks nicer to me.
>
>the macro returns a value just like a function. I chose it because we
>usually prefer return values instead of side-effects. And it's not
>mandatory to use the return value.

I think you mistaken my point. This time I'll write C code instead of
words ;)

+#define __wait_event_interruptible(wq, condition, error) \
+({ \
+ int __ret = 0; \
+ struct wait_queue __wait; \
+ \
+ __wait.task = current; \
+ add_wait_queue(&wq, &__wait); \
+ for (;;) { \
+ current->state = TASK_INTERRUPTIBLE; \
+ if (condition) \
+ break; \
+ if (signal_pending(current)) { \
+ __ret = (error); \
+ break; \
+ } \
+ schedule(); \
+ } \
+ current->state = TASK_RUNNING; \
+ remove_wait_queue(&wq, &__wait); \
+ __ret; \
+})

Andrea Arcangeli


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.048 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site