Cleaning up historical portability baggage

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Cleaning up historical portability baggage
Date: 2022-07-10 01:45:23
Message-ID: CA+hUKGJ3LHeP9w5Fgzdr4G8AnEtJ=z=p6hGDEm4qYGEUX5B6fQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I wonder how much dead code for ancient operating systems we could now
drop. Here are some easier cases, I think, and one tricky one that
might take some debate. I think it makes a lot of sense to say that
we expect at least POSIX-1:2001, because that corresponds to C99, with
the thread option because every targeted system has that.

0001-Remove-dead-pg_pread-and-pg_pwrite-replacement-code.patch
0002-Remove-dead-getrusage-replacement-code.patch
0003-Remove-dead-setenv-unsetenv-replacement-code.patch
0004-Remove-dead-handling-for-pre-POSIX-sigwait.patch
0005-Remove-dead-getpwuid_r-replacement-code.patch
0006-Remove-disable-thread-safety.patch

Clearly there is more stuff like this (eg more _r functions, they're
just a touch more complicated), but this is a start. I mention these
now in case it's helpful for the Meson work, and just generally
because I wanted to clean up after the retirement of ancient HP-UX.
The threads patch probably needs more polish and is extracted from
another series I'll propose in a later CF to do some more constructive
work on threads where it'd be helpful not to have to deal with 'no
threads' builds, but I figured it could also pitch this part along
with the other basic POSIX modernisation stuff.

I pulled the configure output from the oldest releases of each
supported target OS, namely:

* hornet, AIX 7.1
* wrasse, Solaris 11.3
* pollock, illumos rolling
* loach, FreeBSD 12.2
* conchuela, DragonflyBSD 6.0
* morepork, OpenBSD 6.9
* sidewinder, NetBSD 9.2
* prairiedog, macOS 10.4 (vintage system most likely to cause problems)
* clam, Linux 3.10/RHEL 7
* fairiewren, Windows/Mingw with configure

I checked for HAVE_PREAD HAVE_PWRITE HAVE_GETRUSAGE HAVE_SETENV
HAVE_UNSETENV HAVE_GETPWUID_R, and the only missing ones were:

HAVE_PREAD is missing on windows
HAVE_PWRITE is missing on windows
HAVE_GETRUSAGE is missing on windows
HAVE_GETPWUID_R is missing on windows

We either have completely separate code paths or replacement functions
for these.

The pwritev/preadv functions are unfortunately not standardised by
POSIX (I dunno why, it's the obvious combination of the p* and *v
functions) despite every OS in the list having them except for Solaris
and old macOS. Oh well.

Attachment Content-Type Size
0001-Remove-dead-pg_pread-and-pg_pwrite-replacement-code.patch text/x-patch 17.0 KB
0002-Remove-dead-getrusage-replacement-code.patch text/x-patch 3.0 KB
0003-Remove-dead-setenv-unsetenv-replacement-code.patch text/x-patch 8.8 KB
0004-Remove-dead-handling-for-pre-POSIX-sigwait.patch text/x-patch 8.7 KB
0005-Remove-dead-getpwuid_r-replacement-code.patch text/x-patch 5.7 KB
0006-Remove-disable-thread-safety.patch text/x-patch 62.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-07-10 03:00:44 Re: Cleaning up historical portability baggage
Previous Message Ranier Vilela 2022-07-10 00:53:31 Fix gcc warning in sync.c (usr/src/backend/storage/sync/sync.c)