From owner-freebsd-threads@FreeBSD.ORG Mon Feb 4 17:01:14 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C73D16A419; Mon, 4 Feb 2008 17:01:14 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (tim.des.no [194.63.250.121]) by mx1.freebsd.org (Postfix) with ESMTP id 26B9813C461; Mon, 4 Feb 2008 17:01:14 +0000 (UTC) (envelope-from des@des.no) Received: from tim.des.no (localhost [127.0.0.1]) by spam.des.no (Postfix) with ESMTP id 6D8DD207E; Mon, 4 Feb 2008 18:00:58 +0100 (CET) X-Spam-Tests: AWL X-Spam-Learn: disabled X-Spam-Score: -0.2/3.0 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on tim.des.no Received: from ds4.des.no (des.no [80.203.243.180]) by smtp.des.no (Postfix) with ESMTP id E976F2049; Mon, 4 Feb 2008 18:00:57 +0100 (CET) Received: by ds4.des.no (Postfix, from userid 1001) id D26B8844A6; Mon, 4 Feb 2008 18:00:57 +0100 (CET) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: "Karl H. Beckers" 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> Date: Mon, 04 Feb 2008 18:00:57 +0100 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 +0100 \(CET\)") Message-ID: <86ve54d5bq.fsf@ds4.des.no> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-threads@freebsd.org Subject: Re: threading in FreeBSD (acx_pthreads) X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Feb 2008 17:01:14 -0000 "Karl H. Beckers" 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