Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X07kk-0006sj-Vf for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jun 2014 11:22:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X07kk-0005PT-1F for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Jun 2014 11:22:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X07kg-0005PI-VI for pgsql-hackers@postgresql.org; Thu, 26 Jun 2014 11:22:03 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X07kY-0003to-GZ for pgsql-hackers@postgresql.org; Thu, 26 Jun 2014 11:22:00 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 8F977520005; Thu, 26 Jun 2014 13:21:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-5.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC5654.dip0.t-ipconnect.de [93.220.86.84]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id C913A520004; Thu, 26 Jun 2014 13:21:48 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 583E410037B; Thu, 26 Jun 2014 13:21:48 +0200 (CEST) Date: Thu, 26 Jun 2014 13:21:48 +0200 From: Andres Freund To: Robert Haas Cc: Heikki Linnakangas , Tom Lane , Peter Geoghegan , Pg Hackers , Ants Aasma Subject: Re: better atomics - v0.5 Message-ID: <20140626112148.GC1926@awork2.anarazel.de> References: <20140625171434.GG24114@awork2.anarazel.de> <20140625203635.GJ24114@awork2.anarazel.de> <53AB424D.8030306@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2014-06-25 20:22:31 -0400, Robert Haas wrote: > On Wed, Jun 25, 2014 at 5:42 PM, Heikki Linnakangas > wrote: > > I think having a separate file for each architecture is nice. I totally > > agree that they don't belong in src/include/storage, though. s_lock.h has > > always been misplaced there, but we've let it be for historical reasons, but > > now that we're adding a dozen new files, it's time to move them out. > > I find the current organization pretty confusing, but maybe that could > be solved by better documentation of what's supposed to go in each > architecture or compiler-dependent file. The idea is that first a architecture specific file (atomics-arch-*.h) is included. That file can provide a (partial) implementation for the specific architecture. Or it can do pretty much nothing. After that a compiler specific file is included (atomics-generic-*.h). If atomics aren't yet implemented that can provide an intrinsics based implementation if the compiler version has support for it. At the very least a compiler barrier should be provided. After that the spinlock based fallback implementation (atomics-fallback.h) provides atomics and barriers if not yet available. By here we're sure that nothing else will provide them. Then we can provide operations (atomics-generic.h) that build ontop of the provided functions. E.g. implement _sub, _and et al. I'll include some more of that explanation in the header. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers