]> granicus.if.org Git - postgresql/commit
Make [U]INT64CONST safe for use in #if conditions.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 1 Sep 2017 19:14:18 +0000 (15:14 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 1 Sep 2017 19:14:46 +0000 (15:14 -0400)
commit9d6b160d7db76809f0c696d9073f6955dd5a973a
tree5ec2c6e5dd26c060419322f18e1874a240e888cc
parenta0572203532560423c92066b90d13383720dce3a
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
configure
configure.in
src/include/c.h
src/include/pg_config.h.in
src/include/pg_config.h.win32