From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UtzzU-0006fZ-D7 for qemu-devel@nongnu.org; Tue, 02 Jul 2013 08:47:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UtzzS-00008T-RW for qemu-devel@nongnu.org; Tue, 02 Jul 2013 08:47:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6051) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Utztz-00061M-Te for qemu-devel@nongnu.org; Tue, 02 Jul 2013 08:41:48 -0400 Message-ID: <51D2C0D4.2020108@redhat.com> Date: Tue, 02 Jul 2013 14:00:20 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <51D29F27.9040706@siemens.com> <51D2B661.3030604@suse.de> <51D2B978.8070903@redhat.com> <51D2BD1D.6010308@siemens.com> <51D2BE47.7070603@redhat.com> <51D2BF03.1060203@siemens.com> In-Reply-To: <51D2BF03.1060203@siemens.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qom: Use atomics for object refcounting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: Liu Ping Fan , =?ISO-8859-1?Q?Andreas_F=E4rber?= , qemu-devel Il 02/07/2013 13:52, Jan Kiszka ha scritto: >>> But then atomic_dec_and_test or so. Letting the inc/dec return some >>> >> value leaves room for interpretations (value of before or after the >>> >> modification?). >> > >> > In qemu, I made all atomic_* functions return the old value. This is >> > consistent with atomic_cmpxchg and atomic_xchg (where returning the new >> > value makes no sense). > Please avoid this ambiguity by naming the functions properly. That xchg > returns old values is known, that dec and inc do, is surely not. IMO the ambiguity is resolved simply by looking at the docs or existing code, but I can rename them to atomic_fetch_{add,sub,and,or,inc,dec} and add void versions without "fetch". Paolo