Bug 240990 - Linuxulator: CLOCK_THREAD_CPUTIME_ID and CLOCK_PROCESS_CPUTIME_ID are missing
Summary: Linuxulator: CLOCK_THREAD_CPUTIME_ID and CLOCK_PROCESS_CPUTIME_ID are missing
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Yuri Pankov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-02 00:38 UTC by Alex S
Modified: 2020-01-08 17:38 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex S 2019-10-02 00:38:27 UTC
% cat gettime_bug.c
#define _GNU_SOURCE

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

int main() {

  struct timespec t = {.tv_sec = 0, .tv_nsec = 0};

  int err1 = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &t);
  printf("clock_gettime: %d [%s]\n", err1, strerror(errno));

  int err2 = clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t);
  printf("clock_gettime: %d [%s]\n", err2, strerror(errno));

  return 0;
}
% /compat/linux/bin/cc -Wall --sysroot=/compat/linux gettime_bug.c -o gettime_bug
% ./gettime_bug
clock_gettime: -1 [Invalid argument]
clock_gettime: -1 [Invalid argument]
Comment 1 Alex S 2019-10-02 00:50:20 UTC
This is necessary for anything based on Chromium, see https://cs.chromium.org/chromium/src/base/time/time_now_posix.cc?l=52&rcl=b6ad4da425c33a31e4e08b67ce070a0c52082358.
Comment 2 Edward Tomasz Napierala freebsd_committer 2020-01-08 17:38:34 UTC
This one's weird.  There is the code to handle them in sys/compat/linux/linux_time.c, but I have honestly no idea what it's trying to do and why.