Re: __attribute__ for non-gcc compilers

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Oskari Saarenmaa <os(at)ohmu(dot)fi>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)2ndquadrant(dot)com>
Subject: Re: __attribute__ for non-gcc compilers
Date: 2015-01-14 20:48:47
Message-ID: CA+TgmoYpRE+exuMU9eGkYu43KrAHpt0UhHs3=ogcKJeKQ7CCZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 13, 2015 at 4:18 PM, Oskari Saarenmaa <os(at)ohmu(dot)fi> wrote:
> Commit db4ec2ffce35 added alignment attributes for 64-bit atomic
> variables as required on 32-bit platforms using
> __attribute__((aligned(8)). That works fine with GCC, and would work
> with Solaris Studio Compiler [1] and IBM XL C [2], but src/include/c.h
> defines __attribute__ as an empty macro when not using GCC.
> Unfortunately we can't just disable that #define and enable all
> __attributes__ for Solaris CC and XLC as we use a bunch of attributes
> that are not supported by those compilers and using them unconditionally
> would generate a lot of warnings.
>
> Attached a patch that defines custom macros for each attribute and
> enables them individually for compilers that support them and never
> defines __attribute__.
>
> I have tested this with GCC 4.9.2 on Linux x86-64 and Solaris CC 5.12 on
> Sparc (32-bit build); I don't have access to an IBM box with XLC.

I guess my first question is whether we want to be relying on
__attribute__((aligned)) in the first place. If we do, then this
seems like a pretty sensible and necessary change.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-01-14 20:54:20 Re: Safe memory allocation functions
Previous Message Peter Geoghegan 2015-01-14 20:32:54 Re: hung backends stuck in spinlock heavy endless loop