Make futex_wait() use an hrtimer for timeout
[linux-2.6.git] / kernel / futex_compat.c
index 50f24eea6cd02916bd53d0ea09b1b8de668f8823..dff27c471ea6aa55b1a98dfd950310a4e3f784f8 100644 (file)
@@ -141,24 +141,23 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
                struct compat_timespec __user *utime, u32 __user *uaddr2,
                u32 val3)
 {
-       struct timespec t;
-       unsigned long timeout = MAX_SCHEDULE_TIMEOUT;
+       struct timespec ts;
+       ktime_t t, *tp = NULL;
        int val2 = 0;
 
        if (utime && (op == FUTEX_WAIT || op == FUTEX_LOCK_PI)) {
-               if (get_compat_timespec(&t, utime))
+               if (get_compat_timespec(&ts, utime))
                        return -EFAULT;
-               if (!timespec_valid(&t))
+               if (!timespec_valid(&ts))
                        return -EINVAL;
+
+               t = timespec_to_ktime(ts);
                if (op == FUTEX_WAIT)
-                       timeout = timespec_to_jiffies(&t) + 1;
-               else {
-                       timeout = t.tv_sec;
-                       val2 = t.tv_nsec;
-               }
+                       t = ktime_add(ktime_get(), t);
+               tp = &t;
        }
        if (op == FUTEX_REQUEUE || op == FUTEX_CMP_REQUEUE)
                val2 = (int) (unsigned long) utime;
 
-       return do_futex(uaddr, op, val, timeout, uaddr2, val2, val3);
+       return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);
 }