From owner-freebsd-x11@FreeBSD.ORG Thu Feb 28 21:07:43 2008 Return-Path: Delivered-To: freebsd-x11@FreeBSD.org Received: from [127.0.0.1] (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by hub.freebsd.org (Postfix) with ESMTP id E80A31065670; Thu, 28 Feb 2008 21:07:40 +0000 (UTC) (envelope-from jkim@FreeBSD.org) From: Jung-uk Kim To: freebsd-x11@FreeBSD.org Date: Thu, 28 Feb 2008 16:07:25 -0500 User-Agent: KMail/1.6.2 References: <47C320DB.70004@delphij.net> <18371.11144.568407.26227@gromit.timing.com> <20080227103210.694787ec@tom.ulm.sysgo.com> In-Reply-To: <20080227103210.694787ec@tom.ulm.sysgo.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200802281607.30178.jkim@FreeBSD.org> Cc: delphij@delphij.net, Thomas Mueller Subject: Re: Xorg vs gettimeofday() and clock_gettime() X-BeenThere: freebsd-x11@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: X11 on FreeBSD -- maintaining and support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Feb 2008 21:07:43 -0000 On Wednesday 27 February 2008 04:32 am, Thomas Mueller wrote: > On Mon, 25 Feb 2008 13:56:40 -0700, John Hein wrote: > > Xin LI wrote at 12:11 -0800 on Feb 25, 2008: > > > Shall we make some source-level change to Xorg (either > > > upstream under ifdef FreeBSD or our own port, _FAST clocks are > > > not available on some other operating systems) so that we can > > > override the gettimeofday() direct calls and X_GETTIMEOFDAY's > > > to use clock_gettime with a faster clock? > > > > Sounds good to me. > > I vote for putting in a patch in the x11-servers/xorg-server port > > so it gets some quick exposure and then feeding it back upstream > > where it can be added on their schedule. > > FWIW, xorg already has support for clock_gettime(CLOCK_MONOTONIC) > in xorg-server-1.4/os/utils.c: > > _X_EXPORT CARD32 > GetTimeInMillis(void) > { > struct timeval tv; > > #ifdef MONOTONIC_CLOCK > struct timespec tp; > if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) > return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L); > #endif > > X_GETTIMEOFDAY(&tv); > return(tv.tv_sec * 1000) + (tv.tv_usec / 1000); > } > > Apparently the autoconf check for presence of CLOCK_MONOTONIC fails > on FreeBSD: > > #define _POSIX_C_SOURCE 199309L > #include > > int main(int argc, char *argv[]) { > struct timespec tp; > > if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) > return 0; > else > return 1; > } > > /usr/include/time.h: > #if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112 > #define CLOCK_REALTIME 0 > [...] > #define CLOCK_MONOTONIC 4 > > Was CLOCK_MONOTONIC already defined for _POSIX_C_SOURCE 199309? So this test was introduced in the following commit: http://lists.freedesktop.org/archives/xorg-commit/2006-November/009390.html Google found me this: http://www.opengroup.org/austin/mailarchives/ag-review/msg00489.html 'The recently-approved 1003.1j-2000 adds CLOCK_MONOTONIC to the list.' I think 1003.1b-1993 added clock_gettime(2) and configure.ac tests bogus spec. Jung-uk Kim