public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Brownell <david-b@pacbell.net>
To: Oliver Neukum <oliver@neukum.name>
Cc: linux-kernel@vger.kernel.org
Subject: Re: question on macros in wait.h
Date: Thu, 20 Mar 2003 22:52:06 -0800	[thread overview]
Message-ID: <3E7AB696.40204@pacbell.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]


  > is there some deeper reason that there's no macro for waiting
  > uninterruptablely with a timeout? Or did just nobody feel a need
  > as yet?

Those macros seem to have moved out of <linux/sched.h> (2.4)
and wait_event_interruptible_timeout() was added about 6
months ago; the changelog entry says it was for smbfs.
So I'd guess "no need yet".

Here's an updated version of your patch, now using the same
calling convention that the other two "can return 'early'"
calls there provide.  It's behaved in my testing, to replace the
chaos in the usb synchronous call wrappers.

- Dave


[-- Attachment #2: sched3.patch --]
[-- Type: text/plain, Size: 962 bytes --]

--- 1.7/include/linux/wait.h	Sun Nov 17 12:30:14 2002
+++ edited/include/linux/wait.h	Thu Mar 20 21:57:52 2003
@@ -173,6 +173,32 @@
 	__ret;								\
 })
 
+#define __wait_event_timeout(wq, condition, ret)			\
+do {									\
+	wait_queue_t __wait;						\
+	init_waitqueue_entry(&__wait, current);				\
+									\
+	add_wait_queue(&wq, &__wait);					\
+	for (;;) {							\
+		set_current_state(TASK_UNINTERRUPTIBLE);		\
+		if (condition)						\
+			break;						\
+		ret = schedule_timeout(ret);				\
+		if (!ret)						\
+			break;						\
+	}								\
+	current->state = TASK_RUNNING;					\
+	remove_wait_queue(&wq, &__wait);				\
+} while (0)
+
+#define wait_event_timeout(wq, condition, timeout)			\
+({									\
+	long __ret = timeout;						\
+	if (!(condition))						\
+		__wait_event_timeout(wq, condition, __ret);		\
+	__ret;								\
+})
+	
 #define __wait_event_interruptible_timeout(wq, condition, ret)		\
 do {									\
 	wait_queue_t __wait;						\

             reply	other threads:[~2003-03-21  6:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-21  6:52 David Brownell [this message]
2003-03-21 11:38 ` question on macros in wait.h Oliver Neukum
  -- strict thread matches above, loose matches on Subject: below --
2003-03-19 17:47 Oliver Neukum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E7AB696.40204@pacbell.net \
    --to=david-b@pacbell.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver@neukum.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox