Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 04 Feb 2008 18:00:57 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        "Karl H. Beckers" <karl.h.beckers@gmx.net>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: threading in FreeBSD (acx_pthreads)
Message-ID:  <86ve54d5bq.fsf@ds4.des.no>
In-Reply-To: <43451.192.9.112.196.1202141118.squirrel@www.our-isp.org> (Karl H. Beckers's message of "Mon\, 4 Feb 2008 17\:05\:18 %2B0100 \(CET\)")
References:  <5913.192.9.112.196.1202124683.squirrel@www.our-isp.org> <86ve54epyy.fsf@ds4.des.no> <43451.192.9.112.196.1202141118.squirrel@www.our-isp.org>

next in thread | previous in thread | raw e-mail | index | archive | help
"Karl H. Beckers" <karl.h.beckers@gmx.net> writes:
> What I understood now is:
> On current versions -lpthread should work. On some older versions I should
> be using -lthr (so not -lc_r, then?).
> Is there a safe way to check whether we're running a version that needs
> -lthr? In the varnish example you provided, I cannot find a check for
> it?!?

Sure you can.  It explicitly tries -lthr *before* -lpthread, and -lc_r
as a final resort.  The AC macro used will try each in sequence until
one works, and stick with that.

If your configure.ac only covers a single multi-threaded program, you
can make do with just the AC_SEARCH_LIBS invocation:

AC_SEARCH_LIBS(pthread_create, [thr pthread c_r])

If your configure.ac covers several programs, some of which are multi-
threaded and some of which aren't, you should use the full block, and
explicitly add ${PTHREAD_LIBS} to foo_LDADD in Makefile.am for the
multi-threaded programs only.

This has been tested on FreeBSD [678], various Linux distributions
(mostly 2.6-based), Mac OS X (10.3 and up) and Solaris 10.

On FreeBSD 7 and 8 and everything else I mentioned, -lpthread is fine,
but on FreeBSD 6, -lpthread will give you libkse which doesn't work,
hence -lthr to force libthr over libkse.  IIRC, -lc_r is required for
certain FreeBSD platforms which don't have kernel-assisted threads, but
I'm pretty sure Varnish wouldn't be able to handle any kind of load if
built with libc_r.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86ve54d5bq.fsf>