blob: c7c1031b5708373950b8bd5dcaedd6de089aaf34 [file] [log] [blame]
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Unfortunately, nacl-glibc's clock_gettime.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_gettime(clockid_t clk_id, struct timespec *tp) {
switch (clk_id) {
case CLOCK_MONOTONIC:
case CLOCK_PROCESS_CPUTIME_ID:
case CLOCK_REALTIME:
case CLOCK_THREAD_CPUTIME_ID: {
if (!tp) {
errno = EFAULT;
return -1;
}
struct nacl_abi_timespec nacl_tp;
int result = __nacl_irt_clock_gettime(clk_id, &nacl_tp);
if (result != 0) {
errno = result;
return -1;
}
__nacl_abi_timespec_to_timespec(&nacl_tp, tp);
return 0;
}
default:
errno = EINVAL;
return -1;
}
}