All pastes #819672 Raw Edit

Something

public text v1 · immutable
·published 2007-12-17 03:20 UTC
rendered paste body
/*
 * Just like DRM_WAIT_ON, but waits for the wakeup, rather than
 * polling at HZ/100
 */

#define DRM_WAIT_ON_BLOCK( ret, queue, timeout, condition )     \
do {                                                            \
        long _time_remaining = timeout;                         \
        DECLARE_WAITQUEUE(entry, current);                      \
        add_wait_queue(&(queue), &entry);                       \
                                                                \
        for (;;) {                                              \
                __set_current_state(TASK_INTERRUPTIBLE);        \
                if (condition)                                  \
                        break;                                  \
                if (_time_remaining <= 0) {                     \
                        ret = -EBUSY;                           \
                        break;                                  \
                }                                               \
                if (signal_pending(current)) {                  \
                        ret = -EINTR;                           \
                        break;                                  \
                }                                               \
                _time_remaining = schedule_timeout(_time_remaining);    \
        }                                                       \
        remove_wait_queue(&(queue), &entry);                    \
        __set_current_state(TASK_RUNNING);                      \
} while (0)