From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15718 invoked by alias); 18 Jul 2008 15:23:23 -0000 Received: (qmail 15710 invoked by uid 22791); 18 Jul 2008 15:23:23 -0000 X-Spam-Check-By: sourceware.org Received: from mail.enyo.de (HELO mail.enyo.de) (212.9.189.167) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 18 Jul 2008 15:23:03 +0000 Received: from deneb.vpn.enyo.de ([212.9.189.177] helo=deneb.enyo.de) by mail.enyo.de with esmtp id 1KJrnQ-0008QG-Je; Fri, 18 Jul 2008 17:23:00 +0200 Received: from fw by deneb.enyo.de with local (Exim 4.69) (envelope-from ) id 1KJrnQ-0005Dk-81; Fri, 18 Jul 2008 17:23:00 +0200 From: Florian Weimer To: Ian Lance Taylor Cc: gcc-help@gcc.gnu.org Subject: Re: Writing a thread-safe library without pulling in pthreads References: <87d4lbmk6t.fsf@mid.deneb.enyo.de> Date: Fri, 18 Jul 2008 16:05:00 -0000 In-Reply-To: (Ian Lance Taylor's message of "Fri, 18 Jul 2008 08:19:38 -0700") Message-ID: <877ibjdxnv.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-07/txt/msg00219.txt.bz2 * Ian Lance Taylor: > Florian Weimer writes: > >> I'd like to write a library which only uses locking if the application >> is linked against pthreads. Is this possible? > > Yes, and in fact libsupc++ in gcc does it. You can declare the > pthread functions as weak references. Then you only call them if the > address of the function is not NULL. Thanks. But I'm hosed if a library is loaded later (via dlopen) that pulls in threads, right? This looks unsupported, so it should be okay if I can't deal with this situation.