This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Writing a thread-safe library without pulling in pthreads
- From: Ian Lance Taylor <iant at google dot com>
- To: Florian Weimer <fw at deneb dot enyo dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 18 Jul 2008 08:19:38 -0700
- Subject: Re: Writing a thread-safe library without pulling in pthreads
- References: <87d4lbmk6t.fsf@mid.deneb.enyo.de>
Florian Weimer <fw@deneb.enyo.de> 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.
Ian