From: Tom Lane <tgl@sss.pgh.pa.us>
To: Marina Polyakova <m.polyakova@postgrespro.ru>
Cc: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org, Alvaro Herrera <alvherre@alvh.no-ip.org>
Subject: Re: master make check fails on Solaris 10
Date: Mon, 15 Jan 2018 18:41:51 -0500
Message-ID: <18209.1516059711@sss.pgh.pa.us> (raw)
In-Reply-To: <a5559105243efcf6fb619d86c5702115@postgrespro.ru>
References: <0d3a9fa264cebe1cb9966f37b7c06e86@postgrespro.ru>
<20180111173938.jimybeayp2u5mmup@alap3.anarazel.de>
<31a342fa6a025a8bdfc5b8b19c29d56d@postgrespro.ru>
<fc3c1b52d2d4121cccfc13635005bbd0@postgrespro.ru>
<1232.1515780057@sss.pgh.pa.us>
<b946893927ccfd87146d8a7c9f3bbe29@postgrespro.ru>
<15299.1515867055@sss.pgh.pa.us>
<a5559105243efcf6fb619d86c5702115@postgrespro.ru>
Marina Polyakova <m.polyakova@postgrespro.ru> writes:
> On 13-01-2018 21:10, Tom Lane wrote:
>> I'm not sure there's much we can do about this. Dropping the use
>> of the alignment spec isn't a workable option. If there were a
>> simple way for configure to detect that the compiler generates bad
>> code for that, we could have it do so and reject use of __int128,
>> but it'd be up to you to come up with a workable test.
> I'll think about it..
Attached is a possible test program. I can confirm it passes on a
machine with working __int128, but I have no idea whether it will
detect the problem on yours. If not, maybe you can tweak it?
regards, tom lane
Attachments:int128test.c (text/x-c, 1.1K) download
#include <stddef.h>
#include <stdio.h>
/* GCC, Sunpro and XLC support aligned */
#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#endif
typedef __int128 int128a
#if defined(pg_attribute_aligned)
pg_attribute_aligned(8)
#endif
;
/*
* These are globals to discourage the compiler from folding all the
* arithmetic tests down to compile-time constants. We do not have
* convenient support for 128bit literals at this point...
*/
struct glob128
{
__int128 start;
char pad;
int128a a;
int128a b;
int128a c;
int128a d;
} g = {0, 'p', 48828125, 97656255, 0, 0};
int
main()
{
if (offsetof(struct glob128, a) < 17 ||
offsetof(struct glob128, a) > 24)
{
printf("wrong alignment, %d\n", (int) offsetof(struct glob128, a));
return 1;
}
g.a = (g.a << 12) + 1; /* 200000000001 */
g.b = (g.b << 12) + 5; /* 400000000005 */
/* use the most relevant arithmetic ops */
g.c = g.a * g.b;
g.d = (g.c + g.b) / g.b;
/* return different values, to prevent optimizations */
if (g.d != g.a + 1)
{
printf("wrong arithmetic result\n");
return 1;
}
printf("A-OK!\n");
return 0;
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, m.polyakova@postgrespro.ru, andres@anarazel.de, alvherre@alvh.no-ip.org
Subject: Re: master make check fails on Solaris 10
In-Reply-To: <18209.1516059711@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox