[pgpool-hackers: 4585] Re: Fix time_t warnings on OpenBSD
Tatsuo Ishii
ishii at postgresql.org
Mon May 5 14:12:45 JST 2025
> Hello all,
>
> On OpenBSD time_t is defined as __int64_t (which basically always
> results into long long). This causes a lots of compile time warnings
> since pgpool's code expects time_t to be a simple long in a lot of
> places.
>
> POSIX defines time_t as "time_t shall be an integer type". So no
> definition of signedness or size. Since it would be dumb to make it
> unsigned (would be no pre-1970) and I know of no unsigned time_t
> based system I reckon it's safe to assume time_t to be always signed.
> For the size I would like to propose to always upcast to long long.
> This way times can't get truncated and for the places where time_t
> is actually used as a time and not a time diff this would allow pgpool
> to keep working correctly post Y2038 on 64 bit clean time_t systems
> post Y2038 (e.g. i386 OpenBSD).
>
> While here I also changed json_get_long_value_for_key to
> json_get_llong_value_for_key and changed the parameter to long long.
> This makes it more in line _json_value's integer, which is defined as
> int64. This should also give 32 bit platforms proper retrieval of the
> max value of an integer and may or may not solve some weird integer
> overflow issues.
Can we upcast using "int64_t" instead of "long long"? I am hesitate
to use "long long" since its bit width may not be 64bit on certain
systems.
Best regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp
More information about the pgpool-hackers
mailing list