Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Feb 2008 16:07:25 -0500
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        freebsd-x11@FreeBSD.org
Cc:        delphij@delphij.net, Thomas Mueller <tmueller@sysgo.com>
Subject:   Re: Xorg vs gettimeofday() and clock_gettime()
Message-ID:  <200802281607.30178.jkim@FreeBSD.org>
In-Reply-To: <20080227103210.694787ec@tom.ulm.sysgo.com>
References:  <47C320DB.70004@delphij.net> <18371.11144.568407.26227@gromit.timing.com> <20080227103210.694787ec@tom.ulm.sysgo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <time.h>
>
>  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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802281607.30178.jkim>