Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jens Gustedt Newsgroups: comp.lang.c,comp.programming.threads Subject: Re: Trivial C11 threads.h wrapper (public domain) Date: Mon, 01 Oct 2012 08:26:30 +0200 Organization: A noiseless patient Spider Lines: 28 Message-ID: <50693796.8080406@loria.fr> References: <5065EAFD.1050102@loria.fr> <5068B604.9020606@web.de> <5068C9C3.6090502@loria.fr> <5068CB6B.1070900@loria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Injection-Info: mx04.eternal-september.org; posting-host="2590e4fa64e7931a8f955de6703c052f"; logging-data="11287"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19pmHpyLT4p/azwrHEgfaUQbRPJL+UzLuc=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 In-Reply-To: Cancel-Lock: sha1:e1k3SFrIuXZRsIvt/eSinmnPfoA= Xref: csiph.com comp.lang.c:26919 comp.programming.threads:1133 Am 01.10.2012 01:48, schrieb Eric Sosman: > On 9/30/2012 6:44 PM, Jens Gustedt wrote: >> [...] >> Ah, thinking of it a bit more, it is actually not "(void)" which is >> problematic but the fact that the function may result in errno being >> set to a non-zero value. I'll replace by something like >> >> if (pthread_mutex_destroy(&P99_ENCP(p00_mtx))) errno = 0; > > This would be a very bad thing to do in an implementation > that is supposed to imitate a Standard C library function. > > 7.5p3: "The value of errno in the initial thread is zero > at program startup [...] but is never set to zero by any > library function. [...]" > Right. The reason is that I thought that pthread_mutex_destroy could set errno to some error value. But re-reading the manual page of that I see that the error code is in the function return. So there is no need to do that at all. (Otherwise I would have had to capture errno before the call and to restore it if the call to pthread_mutex_destroy failed. Expensive.) Thanks Jens