Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Mar 2015 09:18:40 +0000
From:      David Chisnall <theraven@FreeBSD.org>
To:        Alexey Dokuchaev <danfe@FreeBSD.ORG>
Cc:        Sunpoet Po-Chuan Hsieh <sunpoet@FreeBSD.org>, svn-ports-head@freebsd.org, svn-ports-all@freebsd.org, ports-committers@freebsd.org
Subject:   Re: svn commit: r381955 - head/graphics/gdal
Message-ID:  <22E9C187-E473-40FB-A26C-7666477BEB58@FreeBSD.org>
In-Reply-To: <20150323015759.GA34402@FreeBSD.org>
References:  <201503222011.t2MKBHq7091087@svn.freebsd.org> <20150323015759.GA34402@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 23 Mar 2015, at 01:58, Alexey Dokuchaev <danfe@FreeBSD.ORG> wrote:
>=20
> Is -pthread going away anytime soon?  I'm a bit worried of more alike
> changing one to another; since they're identical right now on FreeBSD,
> I'd rather reduce amount of patching, leaving whatever is picked by
> upstream, unless -lpthread really should be preferred over -pthread
> for some reason I'm unaware of (and ready to learn about).

Tijl's comment on the blog is incomplete.  The history of -pthread goes =
back to the creation of the POSIX threading standard and predates =
FreeBSD implementation.  Pthreads were designed to support multiple =
implementations (N:M with scheduler activations, 1:1 with kernel =
threads, and N:1 with a modified C library that used timer interrupts =
and substituted asynchronous system calls for sync ones).  A number of =
the prototype implementations exposed different things in headers when =
compiling with pthreads support, hidden behind #ifdef _REENTRANT or =
#ifdef _MT.  In particular, a number of fast path macros that only =
worked in the single-threaded case needed removing.  On some systems, =
you needed a completely different set of libc headers.

The -pthread flag was intended as a compiler and linker flag, providing =
the correct predefined macros (and alternate include paths) for the =
system when building with thread support as well as linking the pthread =
library (if one is required).  Today, -pthread on FreeBSD as a linker =
flag is identical to -lpthread.  As a compile flag, I believe that =
-pthread is silently accepted, whereas -lpthread will give a unused =
argument warning.

The -pthread flag was proposed for inclusion in UNIX98, but was never =
consistently or widely adopted.  It's basically dead now, though not =
actively harmful.  There is no particular reason to prefer one form to =
the other (-pthread is, in theory, more portable, though theory and =
practice can differ).

David




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?22E9C187-E473-40FB-A26C-7666477BEB58>