[libvirt] [PATCH v2 1/2] timer impl
Eric Blake
eblake at redhat.com
Wed Dec 15 15:20:46 UTC 2010
On 12/14/2010 07:34 PM, Wen Congyang wrote:
In addition to Hu's comments, and the fact that you are probably going
to revise the exposed interface anyways, here's some additional points.
> * src/util/timer.c src/util/timer.h src/util/timer_linux.c src/util/timer_win32.c:
> timer implementation
> * src/Makefile.am: build timer
> * src/libvirt_private.syms: Export public functions
> * src/libvirt.c: Initialize timer
> * configure.ac: check the functions in librt used by timer
>
> Signed-off-by: Wen Congyang <wency at cn.fujitsu.com>
>
>
> -EXTRA_DIST += util/threads-pthread.c util/threads-win32.c
> +EXTRA_DIST += util/threads-pthread.c util/threads-win32.c \
> + util/timer_linux.c
timer-win32.c? Also, I'd go with timer-linux.c, not timer_linux.c.
> +# timer.h
> +get_clock;
Bad idea to pollute the namespace with get_clock; better would be
something like virGetClock.
> +virNewTimer;
> +virFreeTimer;
> +virModTimer;
> +virDelTimer;
>
> # usb.h
> +
> +static virTimerPtr timer_list = NULL;
> +static void realarm_timer(void);
> +static void __realarm_timer(uint64_t);
It is dangerous to declare functions in the __ namespace, since that is
reserved for libc and friends.
> +uint64_t get_clock(void)
> +{
> + struct timespec ts;
> +
> + clock_gettime(CLOCK_MONOTONIC, &ts);
> + return ts.tv_sec * 1000000000ULL + ts.tv_nsec;
You probably ought to check for overflow here. Dealing with raw
nanoseconds is rather fine-grained; is it any better to go with micro or
even milliseconds, or does libvirt really require something as precise
as nanosecond timeouts?
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101215/f6e87158/attachment-0001.sig>
More information about the libvir-list
mailing list