__attribute__ for non-gcc compilers

From: Oskari Saarenmaa <os(at)ohmu(dot)fi>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>
Subject: __attribute__ for non-gcc compilers
Date: 2015-01-13 21:18:27
Message-ID: 54B58BA3.8040302@ohmu.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

/ Oskari

[1] https://docs.oracle.com/cd/E18659_01/html/821-1384/gjzke.html
[2]
http://www-01.ibm.com/support/knowledgecenter/SSGH2K_11.1.0/com.ibm.xlc111.aix.doc/language_ref/var_attrib_aligned.html

Attachment Content-Type Size
0001-Use-custom-macros-for-all-C-__attributes__.patch text/x-patch 54.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2015-01-13 21:41:32 Re: pg_basebackup fails with long tablespace paths
Previous Message Tom Lane 2015-01-13 19:24:31 Re: EXEC_BACKEND + logging_collector=on is broken