Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Feb 2008 10:32:10 +0100
From:      Thomas Mueller <tmueller@sysgo.com>
To:        John Hein <jhein@timing.com>
Cc:        freebsd-x11@freebsd.org, d@delphij.net
Subject:   Re: Xorg vs gettimeofday() and clock_gettime()
Message-ID:  <20080227103210.694787ec@tom.ulm.sysgo.com>
In-Reply-To: <18371.11144.568407.26227@gromit.timing.com>
References:  <47C320DB.70004@delphij.net> <18371.11144.568407.26227@gromit.timing.com>

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

-- 
Thomas Mueller



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