From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9489 Path: news.gmane.org!not-for-mail From: Pedro Giffuni Newsgroups: gmane.linux.lib.musl.general Subject: Re: FreeBSD's Google Summer of Code 2016 Date: Sat, 5 Mar 2016 19:14:34 -0500 Message-ID: <56DB766A.3050500@FreeBSD.org> References: <56DB3D70.8010601@FreeBSD.org> <20160305212517.GK9349@brightrain.aerifal.cx> <56DB6095.4060204@FreeBSD.org> <20160305233254.GL9349@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1457223241 6930 80.91.229.3 (6 Mar 2016 00:14:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Mar 2016 00:14:01 +0000 (UTC) Cc: musl@lists.openwall.com To: Rich Felker Original-X-From: musl-return-9502-gllmg-musl=m.gmane.org@lists.openwall.com Sun Mar 06 01:14:00 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1acMKe-00014N-Bb for gllmg-musl@m.gmane.org; Sun, 06 Mar 2016 01:14:00 +0100 Original-Received: (qmail 10133 invoked by uid 550); 6 Mar 2016 00:13:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 10115 invoked from network); 6 Mar 2016 00:13:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1457223224; bh=HD5CZZieYMdyBX5BU7nzrEOq98zipIhROGo69PBB/SQ=; h=Subject:To:References:Cc:From:Date:In-Reply-To:From:Subject; b=SNsm+ccO+WcHSS2HyhYfuIL2YtAEAioz9b5U+oFQYYNVjW/RVCTGdt2yGoyqaUjuVO6jGG/wMFMHHzP1utxHp/IQ4BdMnnegbnlAvVdrwWELC3cEh5p/QxJ252RwbEIA5dZZCtK2MJqTxduJF6CCbHUF2rJndzKi6K+pixD0rE/D8v8pxcZBdT/l3GMIIKwqL8JYX1iRdSYpuv0Xf+lvTV32PcwWLszaaXjLP1duzJMmtaAAqt1GOTcdtsS0EiADGvB1NBFr25FMhiZYyZtzRuRKZowzzM9obT/EynACMHYpnTMJWw8ydlhzHng8FJl+tUDZVC12MaVFWQqkab/zUw== X-Yahoo-Newman-Id: 736880.91441.bm@smtp232.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: tZP0l_kVM1nxs6UEge.r1e7XBpk5__BaW6wSkwoBXs7cjbH QCxDLFno8AhotFHlJ73Z5N0BavEectVuethTwOQL5c4M9tAouhY39NhCz1cN x4VPPYO989kjxNNH.m7UPbatT4kOUX2.fwWgSB3ttDXrDduXL3brWqkLTp2k 8Ff7PUlZQFeS6lF7jxOWx_L8aRXnqqm68YlvqYtKNIiH8GCDxoEU4Myzi.tO AgmfXm242mid3KOFBqb6EVbnoVN61GTWF4YFv84byUgzW3MguNCgpsXQFbb_ _NmPaRDEeIUeH5yy1rwmDc44hN050gpEc_3XbBk7eJB1a.O4tdu4VnumGL3s 6Hzq2xdkL.Ob50.S6rVtd6aVvlzT8Nw8ujZn.UmltRyPPu.EiGUhcTatOBje DmeE13lSSmZFYxshANAiTRYtsq2FZjItLw3gI5JJ9hCygRgCQTimjoqWeiMl v0pQTwQZnzkkLsSZpJZc_RvKrc5WIsTwf63gtmFddBP8.0oslrnUsnHG0GpR TOU2u4_uI_Qk.2Fl.IjhX9Y3c2bmPkfbN X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <20160305233254.GL9349@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:9489 Archived-At: On 03/05/16 18:32, Rich Felker wrote: > On Sat, Mar 05, 2016 at 05:41:25PM -0500, Pedro Giffuni wrote: >> First of all, great to hear there is interest on the musl side too. >> >> I think the biggest precedent of porting linux-oriented C libraries >> came from Debian's kFreeBSD. We accomodated a little by for them >> by defining __FreeBSD_kernel__ in sys/param.h. >> >> While using the optional linux-abi futex in FreeBSD could be an option, >> it is not really the cleanest option. The Debian guys did a port of >> NPTL using regular pthreads: >> Of course I ahould have meant "based on regular FreeBSD kernel services". >> http://thread.gmane.org/gmane.linux.debian.ports.bsd/11702 >> >> I am certain this will require more research but it would be useful >> for other ports as well. > We could ask Petr Salinger for the details, but I am pretty sure FreeBSD has the required functionality natively. > Glibc/NPTL has a lot of what I'd call "gratuitous abstraction" (like > the lll stuff) in their pthread primitives which makes this > "possible". I call it gratuitous because it's really really hard to > achieve correct implementations of the pthread sync primitives that > don't have serious corner-case bugs, and it's unlikely that their > abstractions actually suffice to make correct alternate > implementations. > > musl does not have any such abstraction. We require a compare-and-swap > operation or equivalent on which arbitrary atomic operations can be > constructed, a futex or equivalent operation that's roughly > while(*addr==expected) sleep(), and implement all the sync primitives > just once on top of these. > I am not a threading expert (or even a CS guy), but it sounds like mutex(9) with condvar(9) would do [1]: https://www.freebsd.org/doc/en/books/arch-handbook/locking.html Cheers, Pedro. [1] You can watch the manpages here: https://www.freebsd.org/cgi/man.cgi