pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Make [U]INT64CONST safe for use in #if conditions.
Date: Fri, 01 Sep 2017 19:14:55 +0000
Message-ID: <E1dnrP5-0007ao-Ti@gemulon.postgresql.org> (raw)
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

Make [U]INT64CONST safe for use in #if conditions.

Instead of using a cast to force the constant to be the right width,
assume we can plaster on an L, UL, LL, or ULL suffix as appropriate.
The old approach to this is very hoary, dating from before we were
willing to require compilers to have working int64 types.

This fix makes the PG_INT64_MIN, PG_INT64_MAX, and PG_UINT64_MAX
constants safe to use in preprocessor conditions, where a cast
doesn't work.  Other symbolic constants that might be defined using
[U]INT64CONST are likewise safer than before.

Also fix the SIZE_MAX macro to be similarly safe, if we are forced
to provide a definition for that.  The test added in commit 2e70d6b5e
happens to do what we want even with the hack "(size_t) -1" definition,
but we could easily get burnt on other tests in future.

Back-patch to all supported branches, like the previous commits.

Discussion: https://postgr.es/m/15883.1504278595@sss.pgh.pa.us

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3a0f8e7d3f9a54ab34b69d1fc8c9f7806d67521a

Modified Files
--------------
configure                     | 18 ------------------
configure.in                  | 12 ------------
src/include/c.h               | 21 ++++++++++-----------
src/include/pg_config.h.in    |  4 ----
src/include/pg_config.h.win32 |  8 +-------
5 files changed, 11 insertions(+), 52 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


view thread (7+ messages)  latest in thread

Message-ID: <E1dnrP5-0007ao-Ti@gemulon.postgresql.org>
Permalink:  ../E1dnrP5-0007ao-Ti@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1dnrP5-0007ao-Ti@gemulon.postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Make [U]INT64CONST safe for use in #if conditions.
  In-Reply-To: <E1dnrP5-0007ao-Ti@gemulon.postgresql.org>
  References: <E1dnrP5-0007ao-Ti@gemulon.postgresql.org>

* 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