From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754745Ab1HWUpq (ORCPT ); Tue, 23 Aug 2011 16:45:46 -0400 Received: from terminus.zytor.com ([198.137.202.10]:39692 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751791Ab1HWUpk (ORCPT ); Tue, 23 Aug 2011 16:45:40 -0400 Message-ID: <4E541154.6090805@zytor.com> Date: Tue, 23 Aug 2011 13:45:08 -0700 From: "H. Peter Anvin" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 MIME-Version: 1.0 To: Jeremy Fitzhardinge CC: Christoph Lameter , Linus Torvalds , Peter Zijlstra , Ingo Molnar , the arch/x86 maintainers , Linux Kernel Mailing List , Nick Piggin , Jeremy Fitzhardinge Subject: Re: [PATCH 13/15] x86: add cmpxchg_flag() variant References: <738d736ecffa3bd32df76ae41188aa39c2ace941.1314054734.git.jeremy.fitzhardinge@citrix.com> <4E540548.4080402@goop.org> In-Reply-To: <4E540548.4080402@goop.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/23/2011 12:53 PM, Jeremy Fitzhardinge wrote: > > Yes, that would ideal. The closest you can get is asm goto(), but the > syntax for that would be awful; something like: > > #define cmpxchg_jump(ptr, old, new, fail)\ > asm goto (...) > > > : > : > > again: > old = *thingp; > new = frobulate(old); > cmpxchg_jump(thingp, old, new, again); > /* worked */ > > Would this be useful enough? > Actually there is a trick: static inline bool .... { asm goto(... yes); no: return false; yes: return true; } ... which makes syntax a heckuva lot less awkward. -hpa