Ignore:
Timestamp:
2018-08-23T21:14:56Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Children:
f33c989e
Parents:
e2625b1a
git-author:
Jakub Jermar <jakub@…> (2018-08-21 21:58:52)
git-committer:
Jakub Jermar <jakub@…> (2018-08-23 21:14:56)
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 C99-like or HelenOS-specific
interfaces to libc.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/sleep/sleep.c

    re2625b1a r205f1add  
    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.