Changeset bd41ac52 in mainline for uspace/app/bdsh/cmds


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/app/bdsh/cmds/modules/sleep/sleep.c

    re2625b1a rbd41ac52  
    5757}
    5858
    59 /** Convert string containing decimal seconds to useconds_t.
     59/** Convert string containing decimal seconds to usec_t.
    6060 *
    6161 * @param nptr   Pointer to string.
     
    6363 * @return EOK if conversion was successful.
    6464 */
    65 static errno_t decimal_to_useconds(const char *nptr, useconds_t *result)
     65static errno_t decimal_to_useconds(const char *nptr, usec_t *result)
    6666{
    6767        errno_t ret;
    68         uint64_t whole_seconds;
    69         uint64_t frac_seconds;
     68        sec_t whole_seconds;
     69        usec_t frac_seconds;
    7070        const char *endptr;
    7171
     
    7575                endptr = (char *)nptr;
    7676        } else {
    77                 ret = str_uint64_t(nptr, &endptr, 10, false, &whole_seconds);
     77                ret = str_int64_t(nptr, &endptr, 10, false, &whole_seconds);
    7878                if (ret != EOK)
    7979                        return ret;
     
    8787        } else if (*endptr == '.') {
    8888                nptr = endptr + 1;
    89                 ret = str_uint64_t(nptr, &endptr, 10, true, &frac_seconds);
     89                ret = str_int64_t(nptr, &endptr, 10, true, &frac_seconds);
    9090                if (ret != EOK)
    9191                        return ret;
     
    101101
    102102        /* Check for overflow */
    103         useconds_t total = whole_seconds * 1000000 + frac_seconds;
    104         if (total / 1000000 != whole_seconds)
     103        usec_t total = SEC2USEC(whole_seconds) + frac_seconds;
     104        if (USEC2SEC(total) != whole_seconds)
    105105                return EOVERFLOW;
    106106
     
    115115        errno_t ret;
    116116        unsigned int argc;
    117         useconds_t duration = 0;
     117        usec_t duration = 0;
    118118
    119119        /* Count the arguments */
Note: See TracChangeset for help on using the changeset viewer.