Changeset bd41ac52 in mainline for uspace/lib/c/generic/io/console.c


Ignore:
Timestamp:
2018-08-25T22:21:25Z (6 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/c/generic/io/console.c

    re2625b1a rbd41ac52  
    223223
    224224bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event,
    225     suseconds_t *timeout)
    226 {
    227         struct timeval t0;
    228         gettimeofday(&t0, NULL);
     225    usec_t *timeout)
     226{
     227        struct timespec t0;
     228        getuptime(&t0);
    229229
    230230        if (ctrl->input_aid == 0) {
     
    257257
    258258        /* Update timeout */
    259         struct timeval t1;
    260         gettimeofday(&t1, NULL);
    261         *timeout -= tv_sub_diff(&t1, &t0);
     259        struct timespec t1;
     260        getuptime(&t1);
     261        *timeout -= NSEC2USEC(ts_sub_diff(&t1, &t0));
    262262
    263263        return true;
Note: See TracChangeset for help on using the changeset viewer.