bird & pthreads

Alexander Zubkov green at qrator.net
Tue Sep 30 21:41:38 CEST 2025


Hi all!

I've accidentally found a "mistake" in lib/timer.c (master branch). Mistake
in quotes, because it is rather a configuration mistake, as I found later.
There is a function prototype definition inside "#ifdef USE_PTHREADS",
which is then used outside of it, but in "#ifdef CONFIG_BFD":

#ifdef USE_PTHREADS
...
void wakeup_kick_current(void);
#else
...
#endif
...
void
tm_set(timer *t, btime when)
{
...
#ifdef CONFIG_BFD
  /* Hack to notify BFD loops */
  if ((loop != &main_timeloop) && (t->index == 1))
    wakeup_kick_current();
#endif
}

So in case USE_PTHREADS is not defined and CONFIG_BFD is defined, the
compilation would fail with implicit function declaration error. It could
be reproduced with:

./configure --disable-pthreads --with-protocols=bfd
make
...
lib/timer.c: In function 'tm_set':
lib/timer.c:165:5: error: implicit declaration of function
'wakeup_kick_current' [-Wimplicit-function-declaration]
  165 |     wakeup_kick_current();
      |     ^~~~~~~~~~~~~~~~~~~
make: *** [Makefile:115: obj/lib/timer.o] Error 1

But even moving that function prototype out of "#ifdef USE_PTHREADS" does
not help. It then fails on proto/bfd/io.c using undefined references,
because it uses pthreads unconditionally.

I think it would be better to fail on "configure" stage with a meaningful
message that bfd requires pthreads. I see there is now only a workaround to
exclude bfd from the default set of protocols if pthreads is not enabled.
I've made some patch that shows an error if bfd is enabled and pthreads
support is disabled.

Regards,
Alexander Zubkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20250930/50b8009d/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bfd-require-pthreads.patch
Type: text/x-patch
Size: 572 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20250930/50b8009d/attachment.bin>


More information about the Bird-users mailing list