Re: [PATCH] unified frontend support for pg_malloc et al and palloc/pfree mulation (was xlogreader-v4)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] unified frontend support for pg_malloc et al and palloc/pfree mulation (was xlogreader-v4)
Date: 2013-01-12 23:15:17
Message-ID: 25567.1358032517@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2013-01-12 13:16:56 -0500, Tom Lane wrote:
>> However, using a do-block with a local variable is definitely something
>> worth considering. I'm getting less enamored of the __builtin_constant_p
>> idea after finding out that the gcc boys seem to have curious ideas
>> about what its semantics ought to be:
>> https://bugzilla.redhat.com/show_bug.cgi?id=894515

> I wonder whether __builtin_choose_expr is any better?

Right offhand I don't see how that helps us. AFAICS,
__builtin_choose_expr is the same as x?y:z except that y and z are not
required to have the same datatype, which is okay because they require
the value of x to be determinable at compile time. So we couldn't just
write __builtin_choose_expr((elevel) >= ERROR, ...). That would fail
if elevel wasn't compile-time-constant. We could conceivably do

__builtin_choose_expr(__builtin_constant_p(elevel) && (elevel) >= ERROR, ...)

with the idea of making real sure that that expression reduces to a
compile time constant ... but stacking two nonstandard constructs on
each other seems to me to probably increase our exposure to gcc's
definitional randomness rather than reduce it. I mean, if
__builtin_constant_p can't already be trusted to act like a constant,
why should we trust that __builtin_choose_expr doesn't also have a
curious definition of constant-ness?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2013-01-13 00:09:31 Latex longtable format
Previous Message Tom Lane 2013-01-12 22:50:00 Re: Porting to Haiku