[reSIProcate] Timers: why system time?
Nir Soffer
nirs at hyperms.com
Tue May 19 09:00:16 CDT 2009
On Tue, May 19, 2009 at 3:46 PM, Justin Matthews <jmatthewsr at gmail.com>wrote:
> Hi,
>
> Attached is a proposed mod to enable monotonic Timer's on Windows and
> *unix.
>
[snipped windows solution]
>
> Non-Windows
> =========
>
> * _RESIP_POSIX_MONOTONIC_CLOCK enables the __NR_clock_gettime call. Note
> that on some systems even if _POSIX_MONOTONIC_CLOCK is defined
> __NR_clock_gettime may not be, or may require another library (librt?).
> Some improvement in enabling this could probably be done in the build
> scripts.
>
Why use _NR_clock_gettime? just use clock_gettime.
To get monotonic time from clock_gettime, you have to call it with
CLOCK_MONOTONIC.
To enable the monotonic clock, I suggest to check for CLOCK_MONOTONIC. On
the platforms I used it, ether CLOCK_MONOTONIC is not available (arm,
crosstool toochain), or _POSIX_MONOTONIC_CLOCK is not defined, but
CLOCK_MONOTONIC is (Ubuntu 8.04).
To use the monotonic clock, you have to link with librt (-lrt).
Mac OS X
======
You need to use UpTime() call in DriverServices.h or the routines in
<mach/mach_time.h>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20090519/e505588c/attachment.htm>
More information about the resiprocate-devel
mailing list