From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7651 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Deduplicating atomics written in terms of CAS Date: Sun, 17 May 2015 02:14:30 -0400 Message-ID: <20150517061430.GL17573@brightrain.aerifal.cx> References: <20150517045536.GA25046@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1431843286 24267 80.91.229.3 (17 May 2015 06:14:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 17 May 2015 06:14:46 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7663-gllmg-musl=m.gmane.org@lists.openwall.com Sun May 17 08:14:46 2015 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 1YtrqW-0002br-8u for gllmg-musl@m.gmane.org; Sun, 17 May 2015 08:14:44 +0200 Original-Received: (qmail 28348 invoked by uid 550); 17 May 2015 06:14:42 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28330 invoked from network); 17 May 2015 06:14:42 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:7651 Archived-At: On Sun, May 17, 2015 at 09:00:15AM +0300, Alexander Monakov wrote: > It seems the prototype of a_cas_p has changed: > > void *a_cas_p(volatile void **p, void *t, void *s) > > Shouldn't the type of the first argument be 'void * volatile *'? Yes, thanks for catching it. BTW changing from the current void* to this will probably expose minor aliasing bugs I want to fix. I might just change all pointers used with a_cas_p to uintptr_t, and have a_cas_p work on uintptr_t, and force the code using them to cast back and forth to real pointers. Alternatively we could try to get rid of a_cas_p entirely. I'd like to trim down both the set of atomic primitives we're using and the number of direct uses of atomics (versus higher-level primitives like locks). Some candidates to remove: - a_cas_p - a_or_l (only used in sigaction; could be replaced by a_or) - a_and (not used at all) - a_and_64/a_or_64 (malloc only; these are misnamed too) Actually a_cas_p is the hardest to remove; while none of the users of it are performance-critical themselves, they are using it as a means of avoiding locking where the consumer of the data being written can't or doesn't want to require a lock. Rich