[Xcb] Portability problem; some libcs don't provide pthread stubs

Josh Triplett josh at freedesktop.org
Thu Sep 28 02:27:55 PDT 2006


libxcb makes use of pthreads functions, such as pthread_mutex_lock,
internally.  However, libxcb does not require that applications link
with -lpthread; we want people who link with -lpthread to get thread
functions and a thread-safe libxcb, while allowing people who don't link
with -lpthread to avoid the overhead.  In order to do this, we rely on
the libc stubs for pthread functions.  However, apparently several
platforms, including OSF, AIX, and Hurd, do not provide pthread stubs in
libc.  Thus, when attempting to link an application with libxcb, the
linker fails with undefined symbol errors for pthread functions unless
the application links with -lpthread.

After speaking with several people via IRC, it sounds like the best fix
to preserve existing behavior on these platforms requires checking for
pthread stubs via autoconf, and if not available, defining them in
libxcb as weak aliases, like libX11 does without #define XTHREADS:

int pthread_mutex_init()    __attribute__ ((weak, alias
("_Xthr_zero_stub_")));
static int
_Xthr_zero_stub_()
{
    return(0);
}

- Josh Triplett

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
Url : http://lists.freedesktop.org/archives/xcb/attachments/20060928/cbb46a17/signature.pgp


More information about the Xcb mailing list