Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/thread/fibril.c

    r205f1add rf787c8e  
    6060typedef struct {
    6161        link_t link;
    62         struct timespec expires;
     62        struct timeval expires;
    6363        fibril_event_t *event;
    6464} _timeout_t;
     
    142142}
    143143
    144 static inline errno_t _ready_down(const struct timespec *expires)
     144static inline errno_t _ready_down(const struct timeval *expires)
    145145{
    146146        if (multithreaded)
     
    253253}
    254254
    255 static errno_t _ipc_wait(ipc_call_t *call, const struct timespec *expires)
     255static errno_t _ipc_wait(ipc_call_t *call, const struct timeval *expires)
    256256{
    257257        if (!expires)
     
    261261                return ipc_wait(call, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING);
    262262
    263         struct timespec now;
     263        struct timeval now;
    264264        getuptime(&now);
    265265
    266         if (ts_gteq(&now, expires))
     266        if (tv_gteq(&now, expires))
    267267                return ipc_wait(call, SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING);
    268268
    269         return ipc_wait(call, NSEC2USEC(ts_sub_diff(expires, &now)),
    270             SYNCH_FLAGS_NONE);
     269        return ipc_wait(call, tv_sub_diff(expires, &now), SYNCH_FLAGS_NONE);
    271270}
    272271
     
    276275 * wait after new ready fibrils are added.
    277276 */
    278 static fibril_t *_ready_list_pop(const struct timespec *expires, bool locked)
     277static fibril_t *_ready_list_pop(const struct timeval *expires, bool locked)
    279278{
    280279        if (locked) {
     
    371370static fibril_t *_ready_list_pop_nonblocking(bool locked)
    372371{
    373         struct timespec tv = { .tv_sec = 0, .tv_nsec = 0 };
     372        struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
    374373        return _ready_list_pop(&tv, locked);
    375374}
     
    394393
    395394/* Blocks the current fibril until an IPC call arrives. */
    396 static errno_t _wait_ipc(ipc_call_t *call, const struct timespec *expires)
     395static errno_t _wait_ipc(ipc_call_t *call, const struct timeval *expires)
    397396{
    398397        futex_assert_is_not_locked(&fibril_futex);
     
    431430
    432431/** Fire all timeouts that expired. */
    433 static struct timespec *_handle_expired_timeouts(struct timespec *next_timeout)
    434 {
    435         struct timespec ts;
    436         getuptime(&ts);
     432static struct timeval *_handle_expired_timeouts(struct timeval *next_timeout)
     433{
     434        struct timeval tv;
     435        getuptime(&tv);
    437436
    438437        futex_lock(&fibril_futex);
     
    442441                _timeout_t *to = list_get_instance(cur, _timeout_t, link);
    443442
    444                 if (ts_gt(&to->expires, &ts)) {
     443                if (tv_gt(&to->expires, &tv)) {
    445444                        *next_timeout = to->expires;
    446445                        futex_unlock(&fibril_futex);
     
    536535        (void) arg;
    537536
    538         struct timespec next_timeout;
     537        struct timeval next_timeout;
    539538        while (true) {
    540                 struct timespec *to = _handle_expired_timeouts(&next_timeout);
     539                struct timeval *to = _handle_expired_timeouts(&next_timeout);
    541540                fibril_t *f = _ready_list_pop(to, false);
    542541                if (f) {
     
    616615                _timeout_t *cur = list_get_instance(tmp, _timeout_t, link);
    617616
    618                 if (ts_gteq(&cur->expires, &timeout->expires))
     617                if (tv_gteq(&cur->expires, &timeout->expires))
    619618                        break;
    620619
     
    635634 * @return ETIMEOUT if timed out. EOK otherwise.
    636635 */
    637 errno_t fibril_wait_timeout(fibril_event_t *event,
    638     const struct timespec *expires)
     636errno_t fibril_wait_timeout(fibril_event_t *event, const struct timeval *expires)
    639637{
    640638        assert(fibril_self()->rmutex_locks == 0);
     
    891889}
    892890
    893 void fibril_usleep(usec_t timeout)
    894 {
    895         struct timespec expires;
     891void fibril_usleep(suseconds_t timeout)
     892{
     893        struct timeval expires;
    896894        getuptime(&expires);
    897         ts_add_diff(&expires, USEC2NSEC(timeout));
     895        tv_add_diff(&expires, timeout);
    898896
    899897        fibril_event_t event = FIBRIL_EVENT_INIT;
     
    901899}
    902900
    903 void fibril_sleep(sec_t sec)
    904 {
    905         struct timespec expires;
     901void fibril_sleep(unsigned int sec)
     902{
     903        struct timeval expires;
    906904        getuptime(&expires);
    907905        expires.tv_sec += sec;
     
    918916}
    919917
    920 errno_t fibril_ipc_wait(ipc_call_t *call, const struct timespec *expires)
     918errno_t fibril_ipc_wait(ipc_call_t *call, const struct timeval *expires)
    921919{
    922920        return _wait_ipc(call, expires);
Note: See TracChangeset for help on using the changeset viewer.