[Openais] changing gettimeofday to times

Fabien THOMAS fabien.thomas at netasq.com
Tue Nov 14 10:02:39 PST 2006


times is also marked obsolete under FreeBSD but it is
normal as Darwin came from big part of FreeBSD code.

timer_gettime do not exist under BSD and darwin.
getitimer/setitimer is supported but i dont see how you will use it  
to get a timestamp?

What i generaly use is  a function that retrieve boot time (that we  
already have for each platform)
and gettimeofday to retrieve current time. uptime is then computed by  
now - boot.
The main problem with this is you need to update the cached value of  
boottime each
time a clock change occur or retrieve it each time you call  
gettimeofday.
After that when you can diff the value without problem and convert it  
back to realtime when necessary.

Regards,
Fabien

Le 13 nov. 06 à 20:20, Steven Dake a écrit :

> If the system time is changed while openais is running the timing  
> system
> gets all out of wack.  This is because gettimeofday returns the  
> current
> time, instead of the number of msec since boot and is used in the  
> tlist
> code.
>
> There is a mechanism to determine the number of msec since boot which
> appears to be portable.  The posix API is "times" which returns the
> number of clock ticks since system boot.
>
> The Linux man page says times returns a time value from some time  
> in the
> past but on linux this is the system boot time.
>
> On BSD or Solaris, is this also the case?  I don't have the man  
> pages to
> check these systems and would like a portable solution.  The other
> possibility is getitimer and setitimer or the posix timer_gettime
> absolute time but I think these posix APIs are not supported on all
> platforms.
>
> Regards
> -steve
>
> _______________________________________________
> Openais mailing list
> Openais at lists.osdl.org
> https://lists.osdl.org/mailman/listinfo/openais
>





More information about the Openais mailing list