[libvirt] New compile failure on OSX: CLOCK_REALTIME undeclared

Eric Blake eblake at redhat.com
Mon Nov 8 19:07:57 UTC 2010


On 11/07/2010 01:35 AM, Justin Clift wrote:
> Hi Eric,
> 
> When running 'make check' on OSX (git head) it's erroring out with:
> 
>   eventtest.c: In function 'finishJob':
>   eventtest.c:216: warning: implicit declaration of function 'clock_gettime'
>   eventtest.c:216: warning: nested extern declaration of 'clock_gettime' [-Wnested-externs]
>   eventtest.c:216: error: 'CLOCK_REALTIME' undeclared (first use in this function)
>   eventtest.c:216: error: (Each undeclared identifier is reported only once
>   eventtest.c:216: error: for each function it appears in.)
>   make[3]: *** [eventtest.o] Error 1
>   make[2]: *** [check-am] Error 2
>   make[1]: *** [check-recursive] Error 1
>   make: *** [check-recursive] Error 1
>   $
> 
> Looks like the CLOCK_REALTIME is a glibc Linux thing.  It's in /usr/include/time/bits.h on
> a F13 box.

CLOCK_REALTIME is optional in C99, but required by POSIX:
http://www.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html#tag_13_76

However, gnulib doesn't yet work around this deficiency:
http://www.gnu.org/software/gnulib/manual/gnulib.html#clock_005fgettime

 Portability problems not fixed by Gnulib:

     * This function is missing on some platforms: MacOS X 10.3, IRIX
5.3, Solaris 2.4, mingw, Interix 3.5, BeOS.

> 
> Any idea if gnulib can be used to get around this?

It might be possible, if we can come up with a portable way to get a
decent substitution of reasonable time on all of those platforms.  Right
now, the gnulib clock-time module is GPL, and merely checks whether
clock_{get,set}time are available, and if so, in what library (although
since the module only consists of a single .m4 file, it should be
trivial to relicense it to LGPLv2+).

-- 
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/20101108/282f4ed5/attachment-0001.sig>


More information about the libvir-list mailing list