Changeset bd41ac52 in mainline for uspace/lib/c/generic/private


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.

Location:
uspace/lib/c/generic/private
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/private/async.h

    re2625b1a rbd41ac52  
    4040#include <fibril.h>
    4141#include <fibril_synch.h>
    42 #include <sys/time.h>
     42#include <time.h>
    4343#include <stdbool.h>
    4444
  • uspace/lib/c/generic/private/fibril.h

    re2625b1a rbd41ac52  
    8181
    8282extern void fibril_wait_for(fibril_event_t *);
    83 extern errno_t fibril_wait_timeout(fibril_event_t *, const struct timeval *);
     83extern errno_t fibril_wait_timeout(fibril_event_t *, const struct timespec *);
    8484extern void fibril_notify(fibril_event_t *);
    8585
    86 extern errno_t fibril_ipc_wait(ipc_call_t *, const struct timeval *);
     86extern errno_t fibril_ipc_wait(ipc_call_t *, const struct timespec *);
    8787extern void fibril_ipc_poke(void);
    8888
  • uspace/lib/c/generic/private/futex.h

    re2625b1a rbd41ac52  
    102102 *
    103103 */
    104 static inline errno_t futex_down_composable(futex_t *futex, const struct timeval *expires)
     104static inline errno_t futex_down_composable(futex_t *futex,
     105    const struct timespec *expires)
    105106{
    106107        // TODO: Add tests for this.
     
    109110                return EOK;
    110111
    111         suseconds_t timeout;
     112        usec_t timeout;
    112113
    113114        if (!expires) {
     
    119120                        timeout = 1;
    120121                } else {
    121                         struct timeval tv;
     122                        struct timespec tv;
    122123                        getuptime(&tv);
    123                         timeout = tv_gteq(&tv, expires) ? 1 :
    124                             tv_sub_diff(expires, &tv);
     124                        timeout = ts_gteq(&tv, expires) ? 1 :
     125                            NSEC2USEC(ts_sub_diff(expires, &tv));
    125126                }
    126127
     
    148149}
    149150
    150 static inline errno_t futex_down_timeout(futex_t *futex, const struct timeval *expires)
    151 {
    152         if (expires && expires->tv_sec == 0 && expires->tv_usec == 0) {
     151static inline errno_t futex_down_timeout(futex_t *futex,
     152    const struct timespec *expires)
     153{
     154        if (expires && expires->tv_sec == 0 && expires->tv_nsec == 0) {
    153155                /* Nonblocking down. */
    154156
     
    209211         * trydown.
    210212         */
    211         struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
     213        struct timespec tv = { .tv_sec = 0, .tv_nsec = 0 };
    212214        return futex_down_timeout(futex, &tv) == EOK;
    213215}
  • uspace/lib/c/generic/private/thread.h

    re2625b1a rbd41ac52  
    4949extern void thread_detach(thread_id_t);
    5050extern thread_id_t thread_get_id(void);
    51 extern int thread_usleep(useconds_t);
    52 extern unsigned int thread_sleep(unsigned int);
     51extern void thread_usleep(usec_t);
     52extern void thread_sleep(sec_t);
    5353
    5454#endif
Note: See TracChangeset for help on using the changeset viewer.