blob: 7994d484b2dcae481089a535beb808f2782dfd06 [file] [log] [blame]
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Unfortunately, nacl-glibc's clock_getres.c is heavily depending on
// other code in glibc. So, we track nothing for this file.
//
#include <errno.h>
#include <time.h>
#include <irt_syscalls.h>
#include <nacl_timespec.h>
int clock_getres(clockid_t clk_id, struct timespec *res) {
switch (clk_id) {
case CLOCK_MONOTONIC:
case CLOCK_PROCESS_CPUTIME_ID:
case CLOCK_REALTIME:
case CLOCK_THREAD_CPUTIME_ID: {
struct nacl_abi_timespec nacl_res;
int result = __nacl_irt_clock_getres(clk_id, &nacl_res);
if (result != 0) {
errno = result;
return -1;
}
// The manual says res==NULL is OK.
if (res)
__nacl_abi_timespec_to_timespec(&nacl_res, res);
return 0;
}
default:
errno = EINVAL;
return -1;
}
}