From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Remove check for accept() argument types
Date: Fri, 12 Nov 2021 12:50:53 -0500
Message-ID: <1731092.1636739453@sss.pgh.pa.us> (raw)
In-Reply-To: <1683239.1636726865@sss.pgh.pa.us>
References: <E1mkSdp-0008FH-7Y@gemulon.postgresql.org>
<1440792.1636558888@sss.pgh.pa.us>
<3863895c-d40b-4154-de8f-4961386b2515@enterprisedb.com>
<1683239.1636726865@sss.pgh.pa.us>
I wrote:
> Peter Eisentraut <peter.eisentraut@enterprisedb.com> writes:
>> What does the man page say the correct type
>> would be? size_t?
> The machine's not booted up right now :-(. But I'm pretty sure we
> shouldn't consider using size_t here, as it's not real clear that that
> couldn't be 64 bits on any affected platforms. Your previous research
> said that the desired type is 32 bits on all such platforms, so I think
> that "int" is correct; we need only debate signedness.
Hmm ... now that I'm in my office, I checked this and HPUX 10.20's
accept(2) man page saith
SYNOPSIS
#include <sys/socket.h>
AF_CCITT only
#include <x25/x25addrstr.h>
int accept(int s, void *addr, int *addrlen);
_XOPEN_SOURCE_EXTENDED only
int accept(int s, struct sockaddr *addr, size_t *addrlen);
gaur is using -D_XOPEN_SOURCE_EXTENDED and hence building against the
latter definition. (I found out quite a long time ago that without
_XOPEN_SOURCE_EXTENDED, this platform has a LOT of discrepancies from
SUS v2.) Further down, there's
FUTURE DIRECTION
The default behavior in this release is still the classic HP-UX BSD
Sockets, however it will be changed to X/Open Sockets in some future
release. At that time, any HP-UX BSD Sockets behavior which is
incompatible with X/Open Sockets may be obsoleted. HP customers are
advised to migrate their applications to conform to X/Open
specification (see xopen_networking(7)).
So what it looks like to me is
(1) Original BSD Sockets defined the argument as "int *addrlen".
(I confirmed this by looking in an ancient copy of Stevens'
Unix Network Programming.)
(2) X/Open thought it'd be better to use size_t.
(3) POSIX decided to resolve the conflict by inventing socklen_t.
However, SUS v2 says specifically that socklen_t "is an unsigned opaque
integral type of length of at least 32 bits". The "unsigned" part
was removed in later POSIX editions, which surprises me --- they don't
usually change the standard in the direction of less definiteness.
On the whole, I still think "unsigned int" is our best compromise.
But maybe we should use size_t and cite X/Open as authority.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us, peter.eisentraut@enterprisedb.com, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Remove check for accept() argument types
In-Reply-To: <1731092.1636739453@sss.pgh.pa.us>
* 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