File: clock_gettime.c

package info (click to toggle)
bglibs 2.04%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,500 kB
  • sloc: ansic: 15,824; perl: 674; sh: 63; makefile: 29
file content (19 lines) | stat: -rw-r--r-- 326 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "sysdeps.h"
#ifndef HASCLOCKGETTIME

#include <errno.h>

int clock_gettime(clockid_t clk_id, struct timespec* tp)
{
  struct timeval tv;
  if (clk_id != CLOCK_REALTIME) {
    errno = EINVAL;
    return -1;
  }
  gettimeofday(&tv, 0);
  tp->tv_sec = tv.tv_sec;
  tp->tv_nsec = tv.tv_usec * 1000;
  return 0;
}

#endif