+static int
+futex_istimeout(struct timeval *timeout)
+{
+ int ret;
+ struct timeval tv;
+
+ if (timeout == NULL)
+ return 0;
+
+ ret = gettimeofday(&tv, NULL);
+ if (ret != 0)
+ return ret;
+
+ return (tv.tv_sec > timeout->tv_sec) ||
+ ((tv.tv_sec == timeout->tv_sec) && tv.tv_usec > timeout->tv_usec);
+}
+