From owner-freebsd-hackers@FreeBSD.ORG Sun Oct 14 16:53:08 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 307E9F32 for ; Sun, 14 Oct 2012 16:53:08 +0000 (UTC) (envelope-from freebsd-hackers@m.gmane.org) Received: from plane.gmane.org (plane.gmane.org [80.91.229.3]) by mx1.freebsd.org (Postfix) with ESMTP id DBF7D8FC12 for ; Sun, 14 Oct 2012 16:53:07 +0000 (UTC) Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TNRR1-00058J-Vg for freebsd-hackers@freebsd.org; Sun, 14 Oct 2012 18:53:03 +0200 Received: from dsl-hkibrasgw3-ffd6c300-228.dhcp.inet.fi ([88.195.214.228]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 14 Oct 2012 18:53:03 +0200 Received: from rakuco by dsl-hkibrasgw3-ffd6c300-228.dhcp.inet.fi with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 14 Oct 2012 18:53:03 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: freebsd-hackers@freebsd.org From: Raphael Kubo da Costa Subject: Re: -lpthread vs -pthread: does -D_REENTRANT matter? Date: Sun, 14 Oct 2012 19:52:59 +0300 Lines: 24 Message-ID: <87zk3pnggk.fsf@FreeBSD.org> References: <20121014144222.GA14503@stack.nl> Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dsl-hkibrasgw3-ffd6c300-228.dhcp.inet.fi User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2 (berkeley-unix) Cancel-Lock: sha1:bHLg9z9aPYiFLmKemVP/DHaRnN8= X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Oct 2012 16:53:08 -0000 Jilles Tjoelker writes: > On Mon, Oct 08, 2012 at 12:17:08PM -0400, Eitan Adler wrote: >> The only difference between -lpthread and -pthread that I could see is >> that the latter also sets -D_REENTRANT. >> However, I can't find any uses of _REENTRANT anywhere outside of a few >> utilities that seem to define it manually. > >> Testing with various manually written pthread programs resulted in >> identical binaries, let alone identical results. > >> Is there an actual difference between -pthread and -lpthread or is >> this just a historical artifact? > > In some cases, -pthread also affects the compiler's code generation. On > some RISC architectures, compilers may try to avoid loads and stores of > less than 32 bits. [...] > Because C99 does not specify threading, it allows these transformations. > In C11, they are forbidden. Passing -pthread disables them as well. And does this not happen at all if one uses -lpthread instead?