Bug 23304

Summary: POSIX clock_gettime, clock_getres return errno invalid argument for CLOCK_PROF and CLOCK_VIRTUAL
Product: Base System Reporter: jonathan <jonathan>
Component: kernAssignee: kbyanc
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-STABLE   
Hardware: Any   
OS: Any   

Description jonathan 2000-12-05 21:40:01 UTC
While there is no problem with CLOCK_REALTIME, POSIX clock_gettime, clock_getres return errno invalid argument for CLOCK_PROF and CLOCK_VIRTUAL, which are documented in the man pages (section 2) as being user+system and user time, respectively.

Fix: 

Immediate fix: remove mention of CLOCK_VIRTUAL AND CLOCK_PROF from sys/time.h and man 2 clock_gettime

Real fix: implement the documented POSIX functionality
How-To-Repeat: /* demonstrates that the clock_get... calls succed for CLOCK_REALTIME but fail for CLOCK_PROF and CLOCK_VIRTUAL */
#include <sys/time.h>
#include <stdio.h>

int main() {
  struct timespec t;

  puts("CLOCK_PROF");
  if (clock_gettime(CLOCK_PROF, &t))
    perror(NULL);
  if (clock_getres(CLOCK_PROF, &t))
    perror(NULL);

  puts("\nCLOCK_VIRTUAL");
  if (clock_gettime(CLOCK_VIRTUAL, &t))
    perror(NULL);
  if (clock_getres(CLOCK_VIRTUAL, &t))
    perror(NULL);

  puts("\nCLOCK_REALTIME");
  if (clock_gettime(CLOCK_REALTIME, &t))
    perror(NULL);
  if (clock_getres(CLOCK_REALTIME, &t))
    perror(NULL);
}
Comment 1 Mike Barcroft freebsd_committer freebsd_triage 2002-06-05 03:51:47 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-standards


This is a standards issue.
Comment 2 Johan Karlsson freebsd_committer freebsd_triage 2002-08-25 03:05:18 UTC
Responsible Changed
From-To: freebsd-standards->standards

Use short names for mailing list to make searches    
using the web query form work with the shown responsible. 

This also makes open PR show up in the summery mail.
Comment 3 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2004-02-17 15:46:15 UTC
Responsible Changed
From-To: standards->freebsd-standards

Misattributed PR.
Comment 4 kbyanc freebsd_committer freebsd_triage 2004-06-18 00:22:42 UTC
State Changed
From-To: open->patched

Committed support for CLOCK_VIRTUAL and CLOCK_PROF to -current. 


Comment 5 kbyanc freebsd_committer freebsd_triage 2004-06-18 00:22:42 UTC
Responsible Changed
From-To: freebsd-standards->	 kbyanc

I'll take this in order to help remember I need to do the MFC.
Comment 6 Mark Linimon freebsd_committer freebsd_triage 2007-03-09 00:16:28 UTC
State Changed
From-To: patched->closed

What was -current at the time of this PR was made -stable long ago, so this 
PR is OBE.