Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157030210
D5776.id14729.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D5776.id14729.diff
View Options
Index: sys/compat/linuxkpi/common/include/linux/wait.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/wait.h
+++ sys/compat/linuxkpi/common/include/linux/wait.h
@@ -34,6 +34,7 @@
#include <linux/spinlock.h>
#include <linux/sched.h>
#include <linux/list.h>
+#include <linux/jiffies.h>
#include <sys/param.h>
#include <sys/systm.h>
@@ -113,6 +114,62 @@
-_error; \
})
+#define timer_jiffies_until(expires) \
+({ \
+ int delta = (expires - jiffies); \
+ \
+ if (delta < 1) \
+ delta = 1; \
+ \
+ delta; \
+})
+
+#define wait_event_interruptible_timeout(q, cond, timeout) \
+({ \
+ void *c = &(q).wchan; \
+ long end = jiffies + timeout; \
+ long __ret = 0; \
+ int __rc = 0; \
+ \
+ if (!(cond)) { \
+ for (; __rc == 0;) { \
+ sleepq_lock(c); \
+ if (cond) { \
+ sleepq_release(c); \
+ __ret = 1; \
+ break; \
+ } \
+ sleepq_add(c, NULL, "completion", \
+ SLEEPQ_SLEEP | SLEEPQ_INTERRUPTIBLE, 0); \
+ sleepq_set_timeout(c, timer_jiffies_until(end));\
+ __rc = sleepq_timedwait_sig (c, 0); \
+ if (__rc != 0) { \
+ /* check for timeout or signal. \
+ * 0 if the condition evaluated to false\
+ * after the timeout elapsed, 1 if the \
+ * condition evaluated to true after the\
+ * timeout elapsed. \
+ */ \
+ if (__rc == EWOULDBLOCK) \
+ __ret = (cond); \
+ else \
+ __ret = -ERESTARTSYS; \
+ } \
+ \
+ } \
+ } else { \
+ /* return remaining jiffies (at least 1) if the \
+ * condition evaluated to true before the timeout \
+ * elapsed. \
+ */ \
+ __ret = (end - jiffies); \
+ if( __ret < 1 ) \
+ __ret = 1; \
+ } \
+ __ret; \
+})
+
+
static inline int
waitqueue_active(wait_queue_head_t *q)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 19, 1:10 AM (6 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33282056
Default Alt Text
D5776.id14729.diff (1 KB)
Attached To
Mode
D5776: Implement wait_event_interruptible_timeout.
Attached
Detach File
Event Timeline
Log In to Comment