Changeset bd41ac52 in mainline for uspace/lib/nic/src/nic_impl.c


Ignore:
Timestamp:
2018-08-25T22:21:25Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cca80a2
Parents:
e2625b1a
Message:

Get rid of sys/time.h

This commit moves the POSIX-like time functionality from libc's
sys/time.h to libposix and introduces C11-like or HelenOS-specific
interfaces to libc.

Specifically, use of sys/time.h, struct timeval, suseconds_t and
gettimeofday is replaced by time.h (C11), struct timespec (C11), usec_t
(HelenOS) and getuptime / getrealtime (HelenOS).

Also attempt to fix the implementation of clock() to return microseconds
(clocks) rather than processor cycles and move it to libc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/nic/src/nic_impl.c

    re2625b1a rbd41ac52  
    121121                nic_data->poll_mode = nic_data->default_poll_mode;
    122122                memcpy(&nic_data->poll_period, &nic_data->default_poll_period,
    123                     sizeof(struct timeval));
     123                    sizeof(struct timespec));
    124124                if (rc != EOK) {
    125125                        /*
     
    714714 */
    715715errno_t nic_poll_get_mode_impl(ddf_fun_t *fun,
    716     nic_poll_mode_t *mode, struct timeval *period)
     716    nic_poll_mode_t *mode, struct timespec *period)
    717717{
    718718        nic_t *nic_data = nic_get_from_ddf_fun(fun);
    719719        fibril_rwlock_read_lock(&nic_data->main_lock);
    720720        *mode = nic_data->poll_mode;
    721         memcpy(period, &nic_data->poll_period, sizeof(struct timeval));
     721        memcpy(period, &nic_data->poll_period, sizeof(struct timespec));
    722722        fibril_rwlock_read_unlock(&nic_data->main_lock);
    723723        return EOK;
     
    737737 */
    738738errno_t nic_poll_set_mode_impl(ddf_fun_t *fun,
    739     nic_poll_mode_t mode, const struct timeval *period)
     739    nic_poll_mode_t mode, const struct timespec *period)
    740740{
    741741        nic_t *nic_data = nic_get_from_ddf_fun(fun);
     
    753753                if (period == NULL)
    754754                        return EINVAL;
    755                 if (period->tv_sec == 0 && period->tv_usec == 0)
     755                if (period->tv_sec == 0 && period->tv_nsec == 0)
    756756                        return EINVAL;
    757                 if (period->tv_sec < 0 || period->tv_usec < 0)
     757                if (period->tv_sec < 0 || period->tv_nsec < 0)
    758758                        return EINVAL;
    759759        }
Note: See TracChangeset for help on using the changeset viewer.