Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 9ABDB1542B96 for ; Mon, 19 Dec 2011 11:09:32 -0400 (AST) Received: from exprod7og107.obsmtp.com ([64.18.2.167]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RceqF-0001ov-V4 for pgsql-bugs@postgresql.org; Mon, 19 Dec 2011 15:09:32 +0000 Received: from mail-ee0-f46.google.com ([74.125.83.46]) (using TLSv1) by exprod7ob107.postini.com ([64.18.6.12]) with SMTP ID DSNKTu9TmnpIklR8arY5xLZ5DmdiSiKVig1V@postini.com; Mon, 19 Dec 2011 07:09:27 PST Received: by eekc4 with SMTP id c4so5866892eek.33 for ; Mon, 19 Dec 2011 07:09:13 -0800 (PST) Received: by 10.213.113.203 with SMTP id b11mr2789086ebq.136.1324307353437; Mon, 19 Dec 2011 07:09:13 -0800 (PST) Received: from [192.168.1.101] (dsl-hkibrasgw2-ff6cc300-200.dhcp.inet.fi. [88.195.108.200]) by mx.google.com with ESMTPS id z54sm45606770eeh.5.2011.12.19.07.09.12 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Dec 2011 07:09:12 -0800 (PST) Message-ID: <4EEF5397.8090200@enterprisedb.com> Date: Mon, 19 Dec 2011 17:09:11 +0200 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.24) Gecko/20111114 Icedove/3.1.16 MIME-Version: 1.0 To: Robert Haas CC: PostgreSQL Bugs Subject: Re: [PATCH] Use CC atomic builtins if available [was: Re: TAS patch for building on armel/armhf thumb] References: <4EEB1C77.1000309@enterprisedb.com> <20111218224203.GA2950@piware.de> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201112/150 X-Sequence-Number: 31961 On 19.12.2011 16:31, Robert Haas wrote: > On Sun, Dec 18, 2011 at 5:42 PM, Martin Pitt wrote: >>> It probably makes sense to use it on any platform where it's >>> defined. Presumably an implementation provided by the compiler is >>> always going to be at least as good as any magic assembler >>> incantations we can come up with. >> >> I agree. How about a patch like this? It uses builtin atomics if >> available, and falls back to the custom implementations if not. > > -1. Absent some evidence that gcc's implementations are superior to > ours, I think we should not change stuff that works now. That's > likely to lead to subtle bugs that are hard to find and perhaps > dependent on the exact compiler version used. Ok, we're in disagreement on that then. I don't feel very strongly about it, let's see what others think. One thing that caught my eye: if you use __sync_lock_and_test() to implement S_LOCK(), you really should be using __sync_lock_release() for S_UNLOCK(). Actually, I believe our Itanium (and possibly ARM, too) implementation of S_UNLOCK() is wrong as it is. There is no platform-specific S_UNLOCK() defined for Itanium, so we're using the generic implementation: #if !defined(S_UNLOCK) #define S_UNLOCK(lock) (*((volatile slock_t *) (lock)) = 0) #endif /* S_UNLOCK */ That is not sufficient on platforms with a weak memory model, like Itanium. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com