Re: Cannot find a working 64-bit integer type on Illumos
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Tomas Vondra <tomas@vondra.me>, Peter Eisentraut <peter@eisentraut.org>, Heikki Linnakangas <hlinnaka@iki.fi>, Japin Li <japinli@hotmail.com>, Andres Freund <andres@anarazel.de>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-04T21:44:06Z
Lists: pgsql-hackers
On Thu, Dec 5, 2024 at 10:20 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: > I wrote: > > So apparently, "off_t" was the same as "loff_t" before 962da900a, > > but it no longer is the same on 32-bit machines. > > OK, I see what is happening. On platforms that need it, we define > _FILE_OFFSET_BITS as 64 in pg_config.h to ensure that off_t is > big enough. However, 962da900a did this: > > --- a/src/include/postgres_ext.h > +++ b/src/include/postgres_ext.h > @@ -23,7 +23,7 @@ > #ifndef POSTGRES_EXT_H > #define POSTGRES_EXT_H > > -#include "pg_config_ext.h" > +#include <stdint.h> > > Since c.h reads postgres_ext.h first, <stdint.h> is now pulled in > before pg_config.h, and that in turn pulls in <features.h>, which > locks down the decision that off_t will be 32 bits, as well as some > other decisions we don't want. We can NOT include any system headers > before pg_config.h; I'm surprised we're not seeing related failures on > the Solaris-en, where _LARGEFILE_SOURCE is similarly critical. Ah, right. Oops. > Another rather serious problem here is that we no longer provide > macro PG_INT64_TYPE, which seems rather likely to break applications > that were relying on it. That is part of our external API, we > can't just remove it on a whim. I had concluded that PG_INT64_TYPE wasn't part of our external API but pg_int64 was, based on the comment: /* Define a signed 64-bit integer type for use in client API declarations. */ -typedef PG_INT64_TYPE pg_int64; +typedef int64_t pg_int64; But yeah, I obviously hadn't considered that other interaction, and ... > I think the least painful solution would be to revert the parts > of 962da900a that got rid of pg_config_ext.h and PG_INT64_TYPE. > Since PG_INT64_TYPE is a macro not a typedef, it might be okay > to #define it as int64_t even before we've read that header, > so as not to give up the principle of relying on stdint.h for the > underlying definition. ... yeah that sounds like a plan. Looking into it. > Now that I see this, I'm fairly astonished that there aren't > more problems than we've noticed. I wonder whether it'd be > a good idea to put in a static assert somewhere about the > width of off_t, so that the next screwup of this sort will > be easier to diagnose. Right, we could assert that it hasn't changed from what configure detected.
Commits
-
Move pg_int64 back to postgres_ext.h
- e56a601e0678 19 (unreleased) landed
- 409543da5411 18.0 landed
-
pgbench: Make set_random_seed() 64-bit everywhere.
- 53a2a1564ae4 18.0 landed
-
Use PRI?64 instead of "ll?" in format strings (continued).
- a0ed19e0a9ef 18.0 landed
-
Fix order of -I switches for building pg_regress.o.
- f186f90e55b7 17.5 landed
- cb36f8ec2124 18.0 landed
-
libpq: Deprecate pg_int64.
- 3c86223c9982 18.0 landed
-
Use PRI*64 instead of "ll*" in format strings (minimal trial)
- 15a79c73111f 18.0 landed
-
Fix header inclusion order in c.h.
- 71cb352904c1 18.0 landed
-
Use <stdint.h> and <inttypes.h> for c.h integers.
- 962da900ac8f 18.0 landed
-
Remove traces of BeOS.
- a2d9a9b95ad9 18.0 landed
-
More correct way to check for existence of types, which allows to specify
- 15abc7788e66 7.2.1 cited