diff --git a/src/thread/pthread_getcpuclockid.c b/src/thread/pthread_getcpuclockid.c index cf3d2b84c83391e0efcebe13f5904eaaa344a97d..9df14fb68952463d5e4606ef19fa4f6ca043d2ec 100644 --- a/src/thread/pthread_getcpuclockid.c +++ b/src/thread/pthread_getcpuclockid.c @@ -2,5 +2,6 @@ int pthread_getcpuclockid(pthread_t t, clockid_t *clockid) { - return ENOSYS; + *clockid = (-t->tid-1)*8U + 6; + return 0; } diff --git a/src/time/clock_getcpuclockid.c b/src/time/clock_getcpuclockid.c index 723840b00830c22517fd00224feb55544e50e916..8a0e2d4c3a622f9e8cf11c0cf7300eb1f59b9ea6 100644 --- a/src/time/clock_getcpuclockid.c +++ b/src/time/clock_getcpuclockid.c @@ -5,7 +5,10 @@ int clock_getcpuclockid(pid_t pid, clockid_t *clk) { - if (pid && pid != getpid()) return EPERM; - *clk = CLOCK_PROCESS_CPUTIME_ID; + struct timespec ts; + clockid_t id = (-pid-1)*8U + 2; + int ret = __syscall(SYS_clock_getres, id, &ts); + if (ret) return -ret; + *clk = id; return 0; }