mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 08:48:29 +00:00
Clean up some sleep code
This commit is contained in:
parent
9849b4c7ba
commit
672ccda37c
35 changed files with 310 additions and 598 deletions
13
third_party/nsync/time.h
vendored
13
third_party/nsync/time.h
vendored
|
@ -17,17 +17,21 @@ COSMOPOLITAN_C_START_
|
|||
typedef struct timespec nsync_time;
|
||||
|
||||
/* A deadline infinitely far in the future. */
|
||||
extern const nsync_time nsync_time_no_deadline;
|
||||
#define nsync_time_no_deadline _timespec_max
|
||||
|
||||
/* The zero delay, or an expired deadline. */
|
||||
extern const nsync_time nsync_time_zero;
|
||||
#define nsync_time_zero _timespec_zero
|
||||
|
||||
/* Return the current time since the epoch. */
|
||||
#define nsync_time_now() _timespec_real()
|
||||
|
||||
/* Sleep for the specified delay. Returns the unslept time which may be
|
||||
non-zero if the call was interrupted. */
|
||||
nsync_time nsync_time_sleep(nsync_time delay);
|
||||
#define nsync_time_sleep(a) _timespec_sleep(a)
|
||||
|
||||
/* Sleep until the specified time. Returns 0 on success, and EINTR
|
||||
if the call was interrupted. */
|
||||
#define nsync_time_sleep_until(a) _timespec_sleep_until(a)
|
||||
|
||||
/* Return a+b */
|
||||
#define nsync_time_add(a, b) _timespec_add(a, b)
|
||||
|
@ -44,6 +48,9 @@ nsync_time nsync_time_sleep(nsync_time delay);
|
|||
/* Return the specified number of microseconds as a time. */
|
||||
#define nsync_time_us(a) _timespec_frommicros(a)
|
||||
|
||||
/* Return the specified number of nanoseconds as a time. */
|
||||
#define nsync_time_ns(a) _timespec_fromnanos(a)
|
||||
|
||||
/* Return an nsync_time constructed from second and nanosecond
|
||||
components */
|
||||
#define nsync_time_s_ns(s, ns) ((nsync_time){(int64_t)(s), (unsigned)(ns)})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue