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/cpp/include/__bits/chrono.hpp

    re2625b1a rbd41ac52  
    611611            static time_point now()
    612612            {
    613                 hel::timeval tv{};
    614                 hel::gettimeofday(&tv, nullptr);
    615 
    616                 rep time = tv.tv_usec;
    617                 time += (tv.tv_sec * 1'000'000ul);
     613                hel::timespec ts{};
     614                hel::getrealtime(&ts);
     615
     616                rep time = NSEC2USEC(ts.tv_nsec);
     617                time += (ts.tv_sec * 1'000'000ul);
    618618
    619619                return time_point{duration{time - epoch_usecs}};
     
    654654            static time_point now()
    655655            {
    656                 hel::timeval tv{};
    657                 hel::getuptime(&tv);
    658 
    659                 rep time = tv.tv_usec;
    660                 time += (tv.tv_sec * 1'000'000ul);
     656                hel::timespec ts{};
     657                hel::getuptime(&ts);
     658
     659                rep time = NSEC2USEC(ts.tv_nsec);
     660                time += (ts.tv_sec * 1'000'000ul);
    661661
    662662                return time_point{duration{time}};
Note: See TracChangeset for help on using the changeset viewer.