about XSync extension problem.

Adam Jackson ajax at nwnk.net
Tue Nov 17 14:21:06 PST 2009


On Tue, 2009-11-17 at 10:21 +0800, lantian ai wrote:

> _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);
> }
> 
> May be on desktop  we use clock_gettime, on arm we use gettimeofday.
>
> But when we change the time , both will change? isn't it?

If we were using clock_gettime(CLOCK_REALTIME), then changes to the
system date and time would affect us, same as with gettimeofday().  This
is in fact the _entire_ reason that we use CLOCK_MONOTONIC instead; X's
internal notion of time is related to elapsed time, and not to whatever
the user happened to set the date to.

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.x.org/archives/xorg/attachments/20091117/d6ca7475/attachment.pgp>


More information about the xorg mailing list