1#include <time.h>
2
3#include <assert.h>
4#include <zircon/syscalls.h>
5
6#include "time_conversion.h"
7
8int nanosleep(const struct timespec* req, struct timespec* rem) {
9    // For now, Zircon only provides an uninterruptible nanosleep. If
10    // we ever introduce an asynchronous mechanism that would require
11    // some EINTR-like logic, then we will also want a nanosleep call
12    // which reports back how much time is remaining. Until then,
13    // always report back 0 timeout remaining.
14
15    int ret = _zx_nanosleep(__duration_timespec_to_deadline(*req));
16    assert(ret == 0);
17    if (rem) {
18        *rem = (struct timespec){
19            .tv_sec = 0,
20            .tv_nsec = 0,
21        };
22    }
23    return 0;
24}
25