From owner-freebsd-hackers Tue Dec 5 13:38:55 2000 From owner-freebsd-hackers@FreeBSD.ORG Tue Dec 5 13:38:53 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from molly.straylight.com (molly.straylight.com [209.68.199.242]) by hub.freebsd.org (Postfix) with ESMTP id 0C48937B400 for ; Tue, 5 Dec 2000 13:38:53 -0800 (PST) Received: from dickie (case.straylight.com [209.68.199.244]) by molly.straylight.com (8.11.0/8.10.0) with SMTP id eB5Lcmq27730 for ; Tue, 5 Dec 2000 13:38:48 -0800 From: "Jonathan Graehl" To: Subject: POSIX clock_gettime, clock_getres return errno invalid argument for CLOCK_PROF and CLOCK_VIRTUAL Date: Tue, 5 Dec 2000 13:43:22 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG The resolution (clock_getres) of CLOCK_REALTIME is 783 ns on my 4.2-STABLE/Pentium 2. Is there a more accurate timer available? (clearly, gettimeofday is limited to 1000ns resolution ;) (submitted pr follows) 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. FreeBSD 3jane 4.2-STABLE FreeBSD 4.2-STABLE #0: Sat Dec 2 14:46:10 PST 2000 root@3jane:/ext/obj/usr/src/sys/NEWJANE i386 /* demonstrates that the clock_get... calls succed for CLOCK_REALTIME but fail for CLOCK_PROF and CLOCK_VIRTUAL */ #include #include 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); } 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 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message