[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libevent FTBFS because of TIMEVAL_TO_TIMESPEC



Hi,

thanks for your care about GNU/kFreeBSD.

I was recently looking at the build failure of libevent, which fails
only on kfreebsd (builds fine on hurd and linux).

It looks like it is missing TIMEVAL_TO_TIMESPEC definition. On linux's
glibc it is correctly defined in sys/time.h. On our kfreebsd's glibc
too, but it is wrapped in a #ifdef __USE_GNU.

On all glibc based systems (linux,hurd,GNU/kFreeBSD) <sys/time.h>
is the same. It defines TIMEVAL_TO_TIMESPEC conditionally everywhere.

So it remains to explain why libevent fails on GNU/kFreeBSD
and builds fine on linux.

From long description:
 libevent is meant to replace the asynchronous event loop found in
 event driven network servers.  Currently, libevent supports kqueue(2)
 and select(2).

./configure on linux and hurd:
checking sys/event.h usability... no
checking sys/event.h presence... no
checking for sys/event.h... no

./configure on GNU/kFreeBSD:
checking sys/event.h usability... yes
checking sys/event.h presence... yes
checking for sys/event.h... yes

It tries to use kqueue kernel interface, which is available only on BSDs
(including GNU/kFreeBSD), but not on linux. The builds fails in fact by

kqueue.c:222: warning: implicit declaration of function 'TIMEVAL_TO_TIMESPEC'

The kqueue.c is not built on linux, so it does not fail here.

I've looked at other BDS and (eg. dragonfly) defines it unconditionally.

I've to admit I ignore who should define __USE_GNU (and why) and what
it is used for. I'm also not sure why we can't define that macro without
limits too.

We are glibc based, we should use glibc definition of <sys/time.h>.

The "fix" is easy, just define _GNU_SOURCE in the top of kqueue.c,
similarly as already done in buffer.c, evdns.c, rtsig.c.

Yet better for upstream would be to define _GNU_SOURCE in config.h
on all glibc based systems - via some autoconf test.

Thanks again for your care about GNU/kFreeBSD.

Petr

--- libevent-1.3e/kqueue.c    2007-08-15 02:24:21.000000000 +0200
+++ libevent-1.3e/kqueue.c      2008-08-11 16:36:20.000000000 +0200
@@ -30,6 +30,8 @@
 #include "config.h"
 #endif

+#define _GNU_SOURCE 1
+
 #include <sys/types.h>
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>


Reply to: