On Tue, 21 Sep 2010, Gustavo Sverzut Barbieri wrote:

On Tue, Sep 21, 2010 at 3:27 AM, Vincent Torri <vto...@univ-evry.fr> wrote:


On Tue, 21 Sep 2010, Gustavo Sverzut Barbieri wrote:

Hello all,

As we all know ecore uses gettimeofday() to retrieve the time and
schedule timeouts. Our own code in ecore and even elementary just use
relative times, and we often have to resort to hacks to detect when
timezone changes or user sets time.

In order to solve this problem there is an API called clock_gettime()
that may receive a parameter CLOCK_MONOTONIC. The origin is not
guaranteed (often it is implemented as 0 = machine boot), but it does
guarantee time does not go back.

Raster says that ecore_time_get() and ecore_loop_time_get() are not
supposed to return the unix epoch, although the implementation and
thus the documentation said so... that lead people to use it as such
(a quick grep in svn shows people often save this value to know
timestamps... which is quite wrong).

So we can fix it in 3 ways:

 1. apply the attached patch that turns
ecore_time_get()/ecore_loop_time_get() into monotonic, change
occurrences of ecore_time_get()/ecore_loop_time_get() to be
ecore_unix_time_get() (actually in some places they must be changed to
something else, like gmtime or localtime)

 2. create a new patch that introduces ecore_monotonic_time_get()
and uses that from inside ecore_main.c

 3. change the attached patch to at start do a gettimeofday() and
register the time difference, then always consider that difference. it
would be monotonic but with Epoch as reference... this may be
extremely buggy if the system has a bad battery and clock is just set
by ntp after your efl program is running.

1 is more correct, but maybe too close to 1.0 release to get it, so
although I did the patch I may introduce the way I said in 2...

comments? suggestions?

and for Windows ?

Google returned
http://stackoverflow.com/questions/211257/does-windows-provide-a-monotonically-increasing-clock-to-applications

ok. That's the way I implement gettimeofday :)

Vincent
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to