Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku Newsgroups: comp.os.linux.development.system Subject: Re: Calling libiptc API from a separate thread in a C program throws segmentati Date: Tue, 17 Jan 2012 22:34:48 +0000 (UTC) Organization: A noiseless patient Spider Lines: 35 Message-ID: <20120117141633.815@kylheku.com> References: <20120117102310.171@kylheku.com> <20120117135234.277@kylheku.com> <87d3aif0ea.fsf@araminta.anjou.terraraq.org.uk> Injection-Date: Tue, 17 Jan 2012 22:34:48 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="UCk3K/YilCUd19+i749f3A"; logging-data="6167"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18z0EQBA0Je4f6qWElLx6gDlwnm5BsSUQ4=" User-Agent: slrn/pre1.0.0-18 (Linux) Cancel-Lock: sha1:ksp//n74zcozX7+KiFNlNlAqM48= Xref: x330-a1.tempe.blueboxinc.net comp.os.linux.development.system:384 On 2012-01-17, Richard Kettlewell wrote: > Kaz Kylheku writes: >> Jorgen Grahn wrote: >>>> At one point -pthread was equivalent to -D_REENTRANT and -lpthread, >>>> but that may change in the future if it has not already; it's better >>>> to use the -pthread interface. >>> >>> Either the gcc manual is incomplete, or your explanation is not >> >> Whom are you going to believe, me or the GCC manual? :) > > errno ends up indirected either way though (at least here). "Either way" between which alternatives? The -pthread option will have the effect of defining _REENTRANT so that __errno_location ends up used. But -lpthread alone will not. In /usr/include/bits/errno.h you have this: # ifndef __ASSEMBLER__ /* Function to get address of global `errno' variable. */ extern int *__errno_location (void) __THROW __attribute__ ((__const__)); # if !defined _LIBC || defined _LIBC_REENTRANT /* When using threads, errno is a per-thread value. */ # define errno (*__errno_location ()) # endif # endif /* !__ASSEMBLER__ */ This part is included in /usr/include/errno.h, which then has this: #ifndef errno extern int errno; #endif